Add testcases for `randint`
@@ -27,6 +27,13 @@ class TestRandint(unittest.TestCase):
# int(-0.2) is not less than int(0.3)
random.randint(-0.2, 0.3)
+ def test_lo_hi_nonrandom(self):
+ a = random.randint(-0.9, 1.1, size=3)
+ testing.assert_array_equal(a, cupy.full((3,), 0))
+
+ a = random.randint(-1.1, -0.9, size=(2, 2))
+ testing.assert_array_equal(a, cupy.full((2, 2), -1))
+
def test_zero_sizes(self):
a = random.randint(10, size=(0,))
testing.assert_array_equal(a, cupy.array(()))
@@ -75,6 +82,13 @@ class TestRandint2(unittest.TestCase):
self.assertEqual(min(_.min() for _ in vals), int(low))
self.assertEqual(max(_.max() for _ in vals), int(high) - 1)
+ def test_bound_float2(self):
+ vals = [random.randint(-1.0, 1.0, (2, 3)).get() for _ in range(10)]
+ for val in vals:
+ self.assertEqual(val.shape, (2, 3))
+ self.assertEqual(min(_.min() for _ in vals), -1)
+ self.assertEqual(max(_.max() for _ in vals), 0)
+
@condition.repeat(3, 10)
def test_goodness_of_fit(self):
mx = 5
