Skip to content

Commit

Permalink
No type check for array_attrables, add test for a hover_data dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
guyrosin committed Aug 14, 2023
1 parent a457f0e commit e2a7cb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,9 +1423,7 @@ def build_dataframe(args, constructor):
i for i in args.values() if isinstance(i, str) and i in columns
]
for field in args:
if field in array_attrables and isinstance(
args[field], (list, dict)
):
if args[field] is not None and field in array_attrables:
necessary_columns.extend(
[i for i in args[field] if i in columns]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def test_build_df_from_vaex_and_polars(test_lib):
reason="plotly doesn't use a dataframe interchange protocol for pandas < 2.0.2",
)
@pytest.mark.parametrize("test_lib", ["vaex", "polars"])
def test_build_df_with_hover_data_from_vaex_and_polars(test_lib):
@pytest.mark.parametrize(
"hover_data", [["sepal_width"], {"sepal_length": False, "sepal_width": ":.2f"}]
)
def test_build_df_with_hover_data_from_vaex_and_polars(test_lib, hover_data):
if test_lib == "vaex":
import vaex as lib
else:
Expand All @@ -345,7 +348,7 @@ def test_build_df_with_hover_data_from_vaex_and_polars(test_lib):
data_frame=iris_vaex,
x="petal_width",
y="sepal_length",
hover_data=["sepal_width"],
hover_data=hover_data,
)
out = build_dataframe(args, go.Scatter)
assert_frame_equal(
Expand Down

0 comments on commit e2a7cb4

Please sign in to comment.