Skip to content

Commit

Permalink
Only test boolean column with pandas >= 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Sep 30, 2023
1 parent f445e9d commit 8aa8e5f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/utils/test_core.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,6 +18,8 @@
except ImportError:
pa = None

PANDAS_VERSION = Version(importlib_version("pandas"))


FAKE_CHANNELS_MODULE = f'''
"""Fake channels module for utility tests."""
Expand Down Expand Up @@ -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"),
}
Expand All @@ -154,14 +157,17 @@ 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")
check("count()", data, aggregate="count", type="quantitative")
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():
Expand Down

0 comments on commit 8aa8e5f

Please sign in to comment.