Skip to content

Commit a5515a3

Browse files
Bincount.tests: Add test where values are all zeros or nans
1 parent 841942b commit a5515a3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Orange/tests/test_statistics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@ def test_all_nans(self, array):
417417

418418
np.testing.assert_equal(bincount(x)[0], expected)
419419

420+
@dense_sparse
421+
def test_all_zeros_or_nans(self, array):
422+
"""Sparse arrays with only nans with no explicit zeros will have no non
423+
zero indices. Check that this counts the zeros properly."""
424+
x = array([np.nan] * 5 + [0] * 5)
425+
expected = [5]
426+
427+
np.testing.assert_equal(bincount(x)[0], expected)
428+
420429

421430
class TestUnique(unittest.TestCase):
422431
@dense_sparse

0 commit comments

Comments
 (0)