mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
output tests passing
This commit is contained in:
parent
444e91cdc9
commit
6ff3ad2d4a
@ -1988,7 +1988,7 @@ class Dataframe(Component):
|
||||
):
|
||||
"""
|
||||
Input Parameters:
|
||||
default_value (List[List[Any]]): Default value
|
||||
default_value (List[List[Any]]): Default value as a pandas DataFrame. TODO: Add support for default value as a filepath
|
||||
headers (List[str]): Header names to dataframe. If None, no headers are shown.
|
||||
row_count (int): Limit number of rows for input.
|
||||
col_count (int): Limit number of columns for input. If equal to 1, return data will be one-dimensional. Ignored if `headers` is provided.
|
||||
@ -2150,7 +2150,7 @@ class Timeseries(Component):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
default_value: str = "",
|
||||
default_value: Optional[str] = None,
|
||||
*,
|
||||
x: Optional[str] = None,
|
||||
y: str | List[str] = None,
|
||||
@ -2160,13 +2160,16 @@ class Timeseries(Component):
|
||||
):
|
||||
"""
|
||||
Parameters:
|
||||
default_value: File path for the timeseries csv file.
|
||||
default_value: File path for the timeseries csv file. TODO: Add support for default value as a pd.DataFrame
|
||||
x (str): Column name of x (time) series. None if csv has no headers, in which case first column is x series.
|
||||
y (Union[str, List[str]]): Column name of y series, or list of column names if multiple series. None if csv has no headers, in which case every column after first is a y series.
|
||||
label (str): component name in interface.
|
||||
"""
|
||||
# TODO: Probably incorrect
|
||||
self.default_value = pd.DataFrame(default_value)
|
||||
self.default_value = (
|
||||
pd.read_csv(default_value)
|
||||
if default_value is not None
|
||||
else None
|
||||
)
|
||||
self.x = x
|
||||
if isinstance(y, str):
|
||||
y = [y]
|
||||
|
@ -130,7 +130,7 @@ class TestNumber(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
numeric_input.get_template_context(),
|
||||
{"default": None, "name": "number", "label": None, "css": {}},
|
||||
{"default_value": None, "name": "number", "label": None, "css": {}},
|
||||
)
|
||||
|
||||
def test_in_interface(self):
|
||||
@ -191,7 +191,7 @@ class TestSlider(unittest.TestCase):
|
||||
"minimum": 10,
|
||||
"maximum": 20,
|
||||
"step": 1,
|
||||
"default": 15,
|
||||
"default_value": 15,
|
||||
"name": "slider",
|
||||
"label": "Slide Your Input",
|
||||
"css": {},
|
||||
|
@ -184,6 +184,7 @@ class TestHighlightedText(unittest.TestCase):
|
||||
"label": None,
|
||||
"show_legend": False,
|
||||
"css": {},
|
||||
"default_value": ""
|
||||
},
|
||||
)
|
||||
ht = {"pos": "Hello ", "neg": "World"}
|
||||
@ -231,7 +232,11 @@ class TestAudio(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
audio_output.get_template_context(),
|
||||
{"name": "audio", "label": None, "source": "upload", "css": {}},
|
||||
{"name": "audio",
|
||||
"label": None,
|
||||
"source": "upload",
|
||||
"css": {},
|
||||
"default_value": None},
|
||||
)
|
||||
self.assertTrue(
|
||||
audio_output.deserialize(gr.test_data.BASE64_AUDIO["data"]).endswith(".wav")
|
||||
@ -357,7 +362,7 @@ class TestDataframe(unittest.TestCase):
|
||||
"row_count": 3,
|
||||
"col_count": 3,
|
||||
"col_width": None,
|
||||
"default": [[None, None, None], [None, None, None], [None, None, None]],
|
||||
"default_value": [[None, None, None], [None, None, None], [None, None, None]],
|
||||
"name": "dataframe",
|
||||
},
|
||||
)
|
||||
@ -423,7 +428,7 @@ class TestCarousel(unittest.TestCase):
|
||||
{
|
||||
"name": "textbox",
|
||||
"label": None,
|
||||
"default": "",
|
||||
"default_value": "",
|
||||
"lines": 1,
|
||||
"css": {},
|
||||
"placeholder": None,
|
||||
@ -482,7 +487,8 @@ class TestTimeseries(unittest.TestCase):
|
||||
timeseries_output = gr.outputs.Timeseries(label="Disease")
|
||||
self.assertEqual(
|
||||
timeseries_output.get_template_context(),
|
||||
{"x": None, "y": None, "name": "timeseries", "label": "Disease", "css": {}},
|
||||
{"x": None, "y": None, "name": "timeseries", "label": "Disease", "css": {},
|
||||
"default_value": None},
|
||||
)
|
||||
data = {"Name": ["Tom", "nick", "krish", "jack"], "Age": [20, 21, 19, 18]}
|
||||
df = pd.DataFrame(data)
|
||||
|
Loading…
Reference in New Issue
Block a user