Skip to content

Commit cbdbc46

Browse files
committed
Add tests
1 parent d19fc35 commit cbdbc46

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/_core/test_rules.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def test_variable_type():
5252
assert variable_type(s, boolean_type="categorical") == "categorical"
5353
assert variable_type(s, boolean_type="boolean") == "boolean"
5454

55+
# This should arguably be datmetime, but we don't currently handle it correctly
56+
# Test is mainly asserting that this doesn't fail on the boolean check.
57+
s = pd.timedelta_range(1, periods=3, freq="D").to_series()
58+
assert variable_type(s) == "categorical"
59+
5560
s_cat = s.astype("category")
5661
assert variable_type(s_cat, boolean_type="categorical") == "categorical"
5762
assert variable_type(s_cat, boolean_type="numeric") == "categorical"
@@ -61,6 +66,9 @@ def test_variable_type():
6166
assert variable_type(s, boolean_type="boolean") == "boolean"
6267
assert variable_type(s, boolean_type="boolean", strict_boolean=True) == "numeric"
6368

69+
s = pd.Series([1, 0, 0])
70+
assert variable_type(s, boolean_type="boolean") == "boolean"
71+
6472
s = pd.Series([pd.Timestamp(1), pd.Timestamp(2)])
6573
assert variable_type(s) == "datetime"
6674
assert variable_type(s.astype(object)) == "datetime"

tests/test_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,11 @@ def test_variable_type(self):
15081508
assert variable_type(s.to_numpy()) == "categorical"
15091509
assert variable_type(s.to_list()) == "categorical"
15101510

1511+
# This should arguably be datmetime, but we don't currently handle it correctly
1512+
# Test is mainly asserting that this doesn't fail on the boolean check.
1513+
s = pd.timedelta_range(1, periods=3, freq="D").to_series()
1514+
assert variable_type(s) == "categorical"
1515+
15111516
s = pd.Series([True, False, False])
15121517
assert variable_type(s) == "numeric"
15131518
assert variable_type(s, boolean_type="categorical") == "categorical"

0 commit comments

Comments
 (0)