From e2a7cb4d97c6ee4086cd5984cbf8a7b71837b8a4 Mon Sep 17 00:00:00 2001 From: Guy Rosin Date: Tue, 15 Aug 2023 01:03:09 +0300 Subject: [PATCH] No type check for array_attrables, add test for a hover_data dictionary --- packages/python/plotly/plotly/express/_core.py | 4 +--- .../plotly/tests/test_optional/test_px/test_px_input.py | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index 77d9226b13..274339e58d 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -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] ) diff --git a/packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py b/packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py index 0f2b0668bf..fcb9cf9101 100644 --- a/packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py +++ b/packages/python/plotly/plotly/tests/test_optional/test_px/test_px_input.py @@ -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: @@ -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(