示例#1
0
    def test_hypergeometric_range(self):
        # Test for ticket #921
        assert_(np.all(rnd.hypergeometric(3, 18, 11, size=10) < 4))
        assert_(np.all(rnd.hypergeometric(18, 3, 11, size=10) > 0))

        # Test for ticket #5623
        args = [
            (2**20 - 2, 2**20 - 2, 2**20 - 2),  # Check for 32-bit systems
            (2**30 - 1, 2**30 - 2, 2**30 - 1)
        ]
        for arg in args:
            assert_(rnd.hypergeometric(*arg) > 0)
示例#2
0
    def test_hypergeometric(self):
        rnd.seed(self.seed, self.brng)
        actual = rnd.hypergeometric(10.1, 5.5, 14, size=(3, 2))
        desired = np.array([[10, 9], [9, 10], [9, 10]])
        np.testing.assert_array_equal(actual, desired)

        # Test nbad = 0
        actual = rnd.hypergeometric(5, 0, 3, size=4)
        desired = np.array([3, 3, 3, 3])
        np.testing.assert_array_equal(actual, desired)

        actual = rnd.hypergeometric(15, 0, 12, size=4)
        desired = np.array([12, 12, 12, 12])
        np.testing.assert_array_equal(actual, desired)

        # Test ngood = 0
        actual = rnd.hypergeometric(0, 5, 3, size=4)
        desired = np.array([0, 0, 0, 0])
        np.testing.assert_array_equal(actual, desired)

        actual = rnd.hypergeometric(0, 15, 12, size=4)
        desired = np.array([0, 0, 0, 0])
        np.testing.assert_array_equal(actual, desired)