Skip to content

Commit bdf1447

Browse files
committed
Add one unit test about digitalize
1 parent 1395481 commit bdf1447

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

_unittests/ut_mltree/test_tree_digitize.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ def test_tree_digitize5_false(self):
9595
pred = tree.predict(bins.reshape((-1, 1)))
9696
self.assertEqualArray(expected, pred)
9797

98+
def test_tree_digitize_bigger(self):
99+
x = numpy.array([0, 1, 2, 3, 4, 5, 6, -1], dtype=numpy.float32)
100+
bins = numpy.array([0, 1, 2, 3, 4], dtype=numpy.float32)
101+
expected = numpy.digitize(x, bins, right=True)
102+
tree = digitize2tree(bins, right=True)
103+
pred = tree.predict(x.reshape((-1, 1)))
104+
self.assertEqualArray(expected, pred)
105+
expected = numpy.digitize(bins, bins, right=True)
106+
pred = tree.predict(bins.reshape((-1, 1)))
107+
self.assertEqualArray(expected, pred)
108+
98109

99110
if __name__ == "__main__":
100111
unittest.main()

0 commit comments

Comments
 (0)