From 791c556f201722817dedc18fe7b96866c3a55c40 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Thu, 28 Dec 2023 11:13:56 +1100 Subject: [PATCH] Fix warning due to styling dtyles, and fix column dtype test failure (#238) Fixes #225 --- upsetplot/plotting.py | 5 ++++- upsetplot/tests/test_data.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/upsetplot/plotting.py b/upsetplot/plotting.py index 875ef8b..baf086c 100644 --- a/upsetplot/plotting.py +++ b/upsetplot/plotting.py @@ -656,7 +656,10 @@ def plot_matrix(self, ax): "linewidth": "linewidths", "linestyle": "linestyles", "hatch": "hatch"} - styles = pd.DataFrame(styles).reindex(columns=style_columns.keys()) + styles = (pd.DataFrame(styles) + .reindex(columns=style_columns.keys()) + .astype({"facecolor": 'O', + "edgecolor": 'O', "linewidth": float, "linestyle": 'O', "hatch": 'O'})) styles["linewidth"].fillna(1, inplace=True) styles["facecolor"].fillna(self._facecolor, inplace=True) styles["edgecolor"].fillna(styles["facecolor"], inplace=True) diff --git a/upsetplot/tests/test_data.py b/upsetplot/tests/test_data.py index 07611de..add18e9 100644 --- a/upsetplot/tests/test_data.py +++ b/upsetplot/tests/test_data.py @@ -111,7 +111,8 @@ def test_from_contents_vs_memberships(data, typ, id_column): assert_series_equal(baseline[id_column].reset_index(drop=True), pd.Series(['aa', 'bb', 'cc', 'dd', 'ee', 'ff'], name=id_column)) - assert_frame_equal(baseline.drop([id_column], axis=1), expected) + baseline_without_id = baseline.drop([id_column], axis=1) + assert_frame_equal(baseline_without_id, expected, check_column_type=baseline_without_id.shape[1] > 0) def test_from_contents(typ=set, id_column='id'):