Commit 715a9fbd authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Test mincat/maxcat with missing data

parent fd30e61d
......@@ -117,7 +117,6 @@ def test_isSparse_maxcat():
result = core.isSparse(data, util.CTYPES.integer, maxcat=25)
assert result == (False, None, None)
for actualmaxcat, maxcat in it.product(actualmaxcats, maxcats):
data = np.arange(size)
......@@ -143,6 +142,18 @@ def test_isSparse_maxcat():
assert resultabs == expected
assert resultprop == expected
# when maxcat is a proportion, test should ignore nans
data = np.zeros(100, dtype=np.float)
data[:40] = np.nan
data[40:80] = 1
data = pd.Series(data)
assert core.isSparse(data, None, maxcat=0.5, abscat=False) == \
(True, 'maxcat', 40)
assert core.isSparse(data, None, maxcat=0.6, abscat=False) == \
(True, 'maxcat', 40)
assert core.isSparse(data, None, maxcat=0.7, abscat=False) == \
(False, None, None)
def test_isSparse_mincat():
......@@ -192,6 +203,20 @@ def test_isSparse_mincat():
assert resultabs == expected
assert resultprop == expected
# when mincat is a proportion, test should ignore nans
data = np.zeros(100, dtype=np.float)
data[:40] = np.nan
data[40:60] = 1
data = pd.Series(data)
assert core.isSparse(data, None, mincat=0.1, abscat=False) == \
(False, None, None)
assert core.isSparse(data, None, mincat=0.2, abscat=False) == \
(False, None, None)
assert core.isSparse(data, None, mincat=0.3, abscat=False) == \
(False, None, None)
assert core.isSparse(data, None, mincat=0.4, abscat=False) == \
(True, 'mincat', 20)
def test_isSparse_non_numeric():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment