mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
a238af4d68
* 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>
33 lines
907 B
Python
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"
|