(self)
| 987 | assert_array_equal(actual, desired) |
| 988 | |
| 989 | def test_multivariate_normal(self): |
| 990 | rng = random.RandomState(self.seed) |
| 991 | mean = (.123456789, 10) |
| 992 | cov = [[1, 0], [0, 1]] |
| 993 | size = (3, 2) |
| 994 | actual = rng.multivariate_normal(mean, cov, size) |
| 995 | desired = np.array([[[1.463620246718631, 11.73759122771936], |
| 996 | [1.622445133300628, 9.771356667546383]], |
| 997 | [[2.154490787682787, 12.170324946056553], |
| 998 | [1.719909438201865, 9.230548443648306]], |
| 999 | [[0.689515026297799, 9.880729819607714], |
| 1000 | [-0.023054015651998, 9.201096623542879]]]) |
| 1001 | |
| 1002 | assert_array_almost_equal(actual, desired, decimal=15) |
| 1003 | |
| 1004 | # Check for default size, was raising deprecation warning |
| 1005 | actual = rng.multivariate_normal(mean, cov) |
| 1006 | desired = np.array([0.895289569463708, 9.17180864067987]) |
| 1007 | assert_array_almost_equal(actual, desired, decimal=15) |
| 1008 | |
| 1009 | # Check that non positive-semidefinite covariance warns with |
| 1010 | # RuntimeWarning |
| 1011 | mean = [0, 0] |
| 1012 | cov = [[1, 2], [2, 1]] |
| 1013 | pytest.warns(RuntimeWarning, rng.multivariate_normal, mean, cov) |
| 1014 | |
| 1015 | # and that it doesn't warn with RuntimeWarning check_valid='ignore' |
| 1016 | assert_no_warnings(rng.multivariate_normal, mean, cov, |
| 1017 | check_valid='ignore') |
| 1018 | |
| 1019 | # and that it raises with RuntimeWarning check_valid='raises' |
| 1020 | assert_raises(ValueError, rng.multivariate_normal, mean, cov, |
| 1021 | check_valid='raise') |
| 1022 | |
| 1023 | cov = np.array([[1, 0.1], [0.1, 1]], dtype=np.float32) |
| 1024 | with warnings.catch_warnings(): |
| 1025 | warnings.simplefilter('error', RuntimeWarning) |
| 1026 | rng.multivariate_normal(mean, cov) |
| 1027 | |
| 1028 | mu = np.zeros(2) |
| 1029 | cov = np.eye(2) |
| 1030 | assert_raises(ValueError, rng.multivariate_normal, mean, cov, |
| 1031 | check_valid='other') |
| 1032 | assert_raises(ValueError, rng.multivariate_normal, |
| 1033 | np.zeros((2, 1, 1)), cov) |
| 1034 | assert_raises(ValueError, rng.multivariate_normal, |
| 1035 | mu, np.empty((3, 2))) |
| 1036 | assert_raises(ValueError, rng.multivariate_normal, |
| 1037 | mu, np.eye(3)) |
| 1038 | |
| 1039 | def test_negative_binomial(self): |
| 1040 | rng = random.RandomState(self.seed) |
nothing calls this directly
no test coverage detected