@@ -80,6 +80,11 @@ def test_invalid_array(self):
80
80
assert_raises (ValueError , rnd .RandomState , [1 , 2 , 4294967296 ])
81
81
assert_raises (ValueError , rnd .RandomState , [1 , - 2 , 4294967296 ])
82
82
83
+ def test_non_deterministic (self ):
84
+ rs = rnd .RandomState (brng = 'nondeterministic' )
85
+ rs .rand (10 )
86
+ rs .randint (0 , 10 )
87
+
83
88
class TestBinomial_Intel (TestCase ):
84
89
def test_n_zero (self ):
85
90
# Tests the corner case of n == 0 for the binomial distribution.
@@ -447,8 +452,8 @@ def test_shuffle(self):
447
452
lambda x : np .vstack ([x , x ]).T ,
448
453
# gh-4270
449
454
lambda x : np .asarray ([(i , i ) for i in x ],
450
- [("a" , object , 1 ),
451
- ("b" , np .int32 , 1 )])]:
455
+ [("a" , object , ( 1 ,) ),
456
+ ("b" , np .int32 , ( 1 ,) )])]:
452
457
rnd .seed (self .seed , self .brng )
453
458
alist = conv ([1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ])
454
459
rnd .shuffle (alist )
@@ -633,13 +638,15 @@ def test_logseries(self):
633
638
634
639
635
640
def test_multinomial (self ):
636
- rnd .seed (self .seed , self .brng )
637
- actual = rnd .multinomial (20 , [1 / 6. ]* 6 , size = (3 , 2 ))
638
- desired = np .array ([[[7 , 0 , 2 , 4 , 4 , 3 ], [7 , 1 , 2 , 6 , 4 , 0 ]],
639
- [[2 , 2 , 3 , 4 , 6 , 3 ], [1 , 2 , 5 , 5 , 6 , 1 ]],
640
- [[2 , 7 , 4 , 1 , 2 , 4 ], [3 , 5 , 2 , 5 , 4 , 1 ]]])
641
- np .testing .assert_array_equal (actual , desired )
642
-
641
+ rs = rnd .RandomState (self .seed , brng = self .brng )
642
+ actual = rs .multinomial (20 , [1 / 6. ]* 6 , size = (3 , 2 ))
643
+ desired = np .full ((3 , 2 ), 20 , dtype = actual .dtype )
644
+ np .testing .assert_array_equal (actual .sum (axis = - 1 ), desired )
645
+ expected = np .array ([
646
+ [[6 , 2 , 1 , 3 , 2 , 6 ], [7 , 5 , 1 , 2 , 3 , 2 ]],
647
+ [[5 , 1 , 8 , 3 , 2 , 1 ], [4 , 6 , 0 , 4 , 4 , 2 ]],
648
+ [[6 , 3 , 1 , 4 , 4 , 2 ], [3 , 2 , 4 , 2 , 1 , 8 ]]], actual .dtype )
649
+ np .testing .assert_array_equal (actual , expected )
643
650
644
651
def test_multivariate_normal (self ):
645
652
rnd .seed (self .seed , self .brng )
0 commit comments