From 8aa8e5f815d9e1550259225199ef978364c5e07d Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sat, 30 Sep 2023 12:58:18 -0400 Subject: [PATCH] Only test boolean column with pandas >= 1.0.0 --- tests/utils/test_core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/utils/test_core.py b/tests/utils/test_core.py index 9528bad12..27cd3b7ee 100644 --- a/tests/utils/test_core.py +++ b/tests/utils/test_core.py @@ -1,4 +1,6 @@ import types +from packaging.version import Version +from importlib.metadata import version as importlib_version import numpy as np import pandas as pd @@ -16,6 +18,8 @@ except ImportError: pa = None +PANDAS_VERSION = Version(importlib_version("pandas")) + FAKE_CHANNELS_MODULE = f''' """Fake channels module for utility tests.""" @@ -143,7 +147,6 @@ def check(s, data, **kwargs): { "x": [1, 2, 3, 4, 5], "y": ["A", "B", "C", "D", "E"], - "b": pd.Series([True, False, True, False, None], dtype="boolean"), "z": pd.date_range("2018-01-01", periods=5, freq="D"), "t": pd.date_range("2018-01-01", periods=5, freq="D").tz_localize("UTC"), } @@ -154,7 +157,6 @@ def check(s, data, **kwargs): check("x", data, field="x", type="quantitative") check("y", data, field="y", type="nominal") - check("b", data, field="b", type="nominal") check("z", data, field="z", type="temporal") check("t", data, field="t", type="temporal") check("count(x)", data, field="x", aggregate="count", type="quantitative") @@ -162,6 +164,10 @@ def check(s, data, **kwargs): check("month(z)", data, timeUnit="month", field="z", type="temporal") check("month(t)", data, timeUnit="month", field="t", type="temporal") + if PANDAS_VERSION >= Version("1.0.0"): + data["b"] = pd.Series([True, False, True, False, None], dtype="boolean") + check("b", data, field="b", type="nominal") + @pytest.mark.skipif(pa is None, reason="pyarrow not installed") def test_parse_shorthand_for_arrow_timestamp():