formatting

This commit is contained in:
Abubakar Abid 2022-03-25 16:53:01 -07:00
parent 04b6b80b33
commit c7299edb94
3 changed files with 47 additions and 21 deletions

View File

@ -1055,8 +1055,11 @@ class Image(Component):
else:
self.type = type
self.default_value = processing_utils.encode_url_or_file_to_base64(
default_value) if default_value else None
self.default_value = (
processing_utils.encode_url_or_file_to_base64(default_value)
if default_value
else None
)
self.type = type
self.output_type = "auto"
self.shape = shape
@ -1374,8 +1377,11 @@ class Video(Component):
label (str): component name in interface.
optional (bool): If True, the interface can be submitted with no uploaded video, in which case the input value is None.
"""
self.default_value = processing_utils.encode_url_or_file_to_base64(
default_value) if default_value else None
self.default_value = (
processing_utils.encode_url_or_file_to_base64(default_value)
if default_value
else None
)
self.type = type
self.source = source
super().__init__(label=label, css=css, **kwargs)
@ -1540,8 +1546,11 @@ class Audio(Component):
type (str): The format the image is converted to before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (width, height, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "file" produces a temporary file object whose path can be retrieved by file_obj.name, "filepath" returns the path directly.
label (str): component name in interface.
"""
self.default_value = processing_utils.encode_url_or_file_to_base64(
default_value) if default_value else None
self.default_value = (
processing_utils.encode_url_or_file_to_base64(default_value)
if default_value
else None
)
self.source = source
requires_permissions = source == "microphone"
self.type = type
@ -1847,8 +1856,11 @@ class File(Component):
"""
if "keep_filename" in kwargs:
warnings.warn("keep_filename is deprecated", DeprecationWarning)
self.default_value = processing_utils.encode_url_or_file_to_base64(
default_value) if default_value else None
self.default_value = (
processing_utils.encode_url_or_file_to_base64(default_value)
if default_value
else None
)
self.file_count = file_count
self.type = type
self.test_input = None
@ -2166,9 +2178,7 @@ class Timeseries(Component):
label (str): component name in interface.
"""
self.default_value = (
pd.read_csv(default_value)
if default_value is not None
else None
pd.read_csv(default_value) if default_value is not None else None
)
self.x = x
if isinstance(y, str):

View File

@ -639,7 +639,11 @@ class TestDataframe(unittest.TestCase):
"row_count": 3,
"col_count": 3,
"col_width": None,
"default_value": [[None, None, None], [None, None, None], [None, None, None]],
"default_value": [
[None, None, None],
[None, None, None],
[None, None, None],
],
"name": "dataframe",
"label": "Dataframe Input",
"max_rows": 20,

View File

@ -184,7 +184,7 @@ class TestHighlightedText(unittest.TestCase):
"label": None,
"show_legend": False,
"css": {},
"default_value": ""
"default_value": "",
},
)
ht = {"pos": "Hello ", "neg": "World"}
@ -232,11 +232,13 @@ class TestAudio(unittest.TestCase):
)
self.assertEqual(
audio_output.get_template_context(),
{"name": "audio",
"label": None,
"source": "upload",
"css": {},
"default_value": None},
{
"name": "audio",
"label": None,
"source": "upload",
"css": {},
"default_value": None,
},
)
self.assertTrue(
audio_output.deserialize(gr.test_data.BASE64_AUDIO["data"]).endswith(".wav")
@ -362,7 +364,11 @@ class TestDataframe(unittest.TestCase):
"row_count": 3,
"col_count": 3,
"col_width": None,
"default_value": [[None, None, None], [None, None, None], [None, None, None]],
"default_value": [
[None, None, None],
[None, None, None],
[None, None, None],
],
"name": "dataframe",
},
)
@ -487,8 +493,14 @@ 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": {},
"default_value": None},
{
"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)