diff --git a/tests/_core/test_rules.py b/tests/_core/test_rules.py index 714d5ead5c..161d2af292 100644 --- a/tests/_core/test_rules.py +++ b/tests/_core/test_rules.py @@ -52,6 +52,11 @@ def test_variable_type(): assert variable_type(s, boolean_type="categorical") == "categorical" assert variable_type(s, boolean_type="boolean") == "boolean" + # This should arguably be datmetime, but we don't currently handle it correctly + # Test is mainly asserting that this doesn't fail on the boolean check. + s = pd.timedelta_range(1, periods=3, freq="D").to_series() + assert variable_type(s) == "categorical" + s_cat = s.astype("category") assert variable_type(s_cat, boolean_type="categorical") == "categorical" assert variable_type(s_cat, boolean_type="numeric") == "categorical" @@ -61,6 +66,9 @@ def test_variable_type(): assert variable_type(s, boolean_type="boolean") == "boolean" assert variable_type(s, boolean_type="boolean", strict_boolean=True) == "numeric" + s = pd.Series([1, 0, 0]) + assert variable_type(s, boolean_type="boolean") == "boolean" + s = pd.Series([pd.Timestamp(1), pd.Timestamp(2)]) assert variable_type(s) == "datetime" assert variable_type(s.astype(object)) == "datetime" diff --git a/tests/test_base.py b/tests/test_base.py index eea967cf93..4dfb3edfb4 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1508,6 +1508,11 @@ def test_variable_type(self): assert variable_type(s.to_numpy()) == "categorical" assert variable_type(s.to_list()) == "categorical" + # This should arguably be datmetime, but we don't currently handle it correctly + # Test is mainly asserting that this doesn't fail on the boolean check. + s = pd.timedelta_range(1, periods=3, freq="D").to_series() + assert variable_type(s) == "categorical" + s = pd.Series([True, False, False]) assert variable_type(s) == "numeric" assert variable_type(s, boolean_type="categorical") == "categorical"