Fixes issue with datatype setting in gr.Dataframe. Setting no longer dependent on col_count (#7286)

* fixed

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
cswamy 2024-02-02 17:34:16 +00:00 committed by GitHub
parent a5feb1c8cb
commit 0d36ac05aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
fix:Fixes issue with datatype setting in gr.Dataframe. Setting no longer dependent on col_count

View File

@ -133,9 +133,7 @@ class Dataframe(Component):
if headers is not None
else [str(i) for i in (range(1, self.col_count[0] + 1))]
)
self.datatype = (
datatype if isinstance(datatype, list) else [datatype] * self.col_count[0]
)
self.datatype = datatype
valid_types = ["pandas", "numpy", "array", "polars"]
if type not in valid_types:
raise ValueError(

View File

@ -1112,7 +1112,7 @@ class TestDataframe:
"headers": ["Name", "Age", "Member"],
"row_count": (1, "dynamic"),
"col_count": (3, "dynamic"),
"datatype": ["str", "str", "str"],
"datatype": "str",
"type": "pandas",
"label": "Dataframe Input",
"show_label": True,
@ -1155,7 +1155,7 @@ class TestDataframe:
"headers": ["1", "2", "3"],
"row_count": (1, "dynamic"),
"col_count": (3, "dynamic"),
"datatype": ["str", "str", "str"],
"datatype": "str",
"type": "pandas",
"label": None,
"show_label": True,