MCPcopy Create free account
hub / github.com/numpy/numpy / test_dirichlet

Method test_dirichlet

numpy/random/tests/test_randomstate.py:782–799  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

780 assert_array_almost_equal(actual, desired, decimal=13)
781
782 def test_dirichlet(self):
783 random.seed(self.seed)
784 alpha = np.array([51.72840233779265162, 39.74494232180943953])
785 actual = random.dirichlet(alpha, size=(3, 2))
786 desired = np.array([[[0.54539444573611562, 0.45460555426388438],
787 [0.62345816822039413, 0.37654183177960598]],
788 [[0.55206000085785778, 0.44793999914214233],
789 [0.58964023305154301, 0.41035976694845688]],
790 [[0.59266909280647828, 0.40733090719352177],
791 [0.56974431743975207, 0.43025568256024799]]])
792 assert_array_almost_equal(actual, desired, decimal=15)
793 bad_alpha = np.array([5.4e-01, -1.0e-16])
794 assert_raises(ValueError, random.dirichlet, bad_alpha)
795
796 random.seed(self.seed)
797 alpha = np.array([51.72840233779265162, 39.74494232180943953])
798 actual = random.dirichlet(alpha)
799 assert_array_almost_equal(actual, desired[0, 0], decimal=15)
800
801 def test_dirichlet_size(self):
802 # gh-3173

Callers

nothing calls this directly

Calls 2

assert_raisesFunction · 0.90

Tested by

no test coverage detected