def test_size_is_not_none(self): with mock.patch('cupy.random.sample_.randint') as m: random.random_integers(3, 5, (1, 2, 3)) m.assert_called_with(3, 6, (1, 2, 3))
def test_bound_1(self): vals = [random.random_integers(0, 10, (2, 3)).get() for _ in range(10)] for val in vals: self.assertEqual(val.shape, (2, 3)) self.assertEqual(min(_.min() for _ in vals), 0) self.assertEqual(max(_.max() for _ in vals), 10)
def test_bound_2(self): vals = [random.random_integers(0, 2).get() for _ in range(20)] for val in vals: assert val.shape == () assert min(vals) == 0 assert max(vals) == 2
def test_high_is_none(self): with mock.patch('cupy.random.sample_.randint') as m: random.random_integers(3, None) m.assert_called_with(1, 4, None)
def test_upper_bound(self): val = random.random_integers(0, 2).get() self.assertEqual(2, val)
def test_bound_1(self): vals = [random.random_integers(0, 10, (2, 3)).get() for _ in range(10)] for val in vals: assert val.shape == (2, 3) assert min(_.min() for _ in vals) == 0 assert max(_.max() for _ in vals) == 10
def test_size_is_not_none(self): random.random_integers(3, 5, (1, 2, 3)) random.sample_.randint.assert_called_with(3, 6, (1, 2, 3))
def test_normal(self): random.random_integers(3, 5) random.sample_.randint.assert_called_with(3, 6, None)
def test_high_is_none(self): random.random_integers(3, None) random.sample_.randint.assert_called_with(1, 4, None)
def test_bound_2(self): vals = [random.random_integers(0, 2).get() for _ in range(20)] for val in vals: self.assertEqual(val.shape, ()) self.assertEqual(min(vals), 0) self.assertEqual(max(vals), 2)
def test_within_interval(self): val = random.random_integers(0, 10, (2, 3)).get() numpy.testing.assert_array_less( numpy.full((2, 3), -1, dtype=numpy.int64), val) numpy.testing.assert_array_less( val, numpy.full((2, 3), 11, dtype=numpy.int64))
def test_normal(self): with mock.patch('cupy.random.sample_.randint') as m: random.random_integers(3, 5) m.assert_called_with(3, 6, None)