gradio/test/components/test_native_plots.py
aliabid94 a238af4d68
Refactor plots to drop altair and use vega.js directly (#8807)
* changes

* add changeset

* changes

* changes

* changes

* add changeset

* changes

* add changeset

* changes

* add changeset

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* changes

* add changeset

* changes

* changes

* Update gradio/components/native_plot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/components/native_plot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/blocks.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

* changes

* Update gradio/components/native_plot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/components/native_plot.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2024-07-22 09:52:48 -07:00

33 lines
907 B
Python

import gradio as gr
from .plot_data import barley, simple
class TestNativePlot:
def test_plot_recognizes_correct_datatypes(self):
plot = gr.BarPlot(
value=simple,
x="date",
y="b",
)
assert plot.value["datatypes"]["date"] == "temporal"
assert plot.value["datatypes"]["b"] == "quantitative"
plot = gr.BarPlot(
value=simple,
x="a",
y="b",
color="c",
)
assert plot.value["datatypes"]["a"] == "nominal"
assert plot.value["datatypes"]["b"] == "quantitative"
assert plot.value["datatypes"]["c"] == "quantitative"
def test_plot_accepts_fn_as_value(self):
plot = gr.BarPlot(
value=lambda: barley.sample(frac=0.1, replace=False),
x="year",
y="yield",
)
assert plot.value["mark"] == "bar"