@@ -99,7 +99,9 @@ def test_binomial_n_zero():
9999 zeros = np .zeros (2 , dtype = 'int' )
100100 for p in [0 , .5 , 1 ]:
101101 assert rnd .binomial (0 , p ) == 0
102- np .testing .assert_array_equal (rnd .binomial (zeros , p ), zeros )
102+ actual = rnd .binomial (zeros , p )
103+ np .testing .assert_allclose (actual , zeros )
104+
103105
104106def test_binomial_p_is_nan ():
105107 # Issue #4571.
@@ -330,7 +332,7 @@ def test_randomdist_rand(randomdist):
330332 desired = np .array ([[0.9838694715872407 , 0.019142669625580311 ],
331333 [0.1767608025111258 , 0.70966427633538842 ],
332334 [0.518550637178123 , 0.98780936631374061 ]])
333- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
335+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
334336
335337
336338def test_randomdist_randn (randomdist ):
@@ -339,7 +341,7 @@ def test_randomdist_randn(randomdist):
339341 desired = np .array ([[2.1411609928913298 , - 2.0717866791744819 ],
340342 [- 0.92778018318550248 , 0.55240420724917727 ],
341343 [0.04651632135517459 , 2.2510674226058036 ]])
342- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
344+ np .testing .assert_allclose (actual , desired , atol = 1e- 10 )
343345
344346
345347def test_randomdist_randint (randomdist ):
@@ -354,7 +356,7 @@ def test_randomdist_random_integers(randomdist):
354356 with suppress_warnings () as sup :
355357 w = sup .record (DeprecationWarning )
356358 actual = rnd .random_integers (- 99 , 99 , size = (3 , 2 ))
357- assert_ ( len (w ) == 1 )
359+ assert len (w ) == 1
358360
359361 desired = np .array ([[96 , - 96 ], [- 64 , 42 ], [4 , 97 ]])
360362 np .testing .assert_array_equal (actual , desired )
@@ -370,7 +372,7 @@ def test_random_integers_max_int():
370372 w = sup .record (DeprecationWarning )
371373 actual = rnd .random_integers (np .iinfo ('l' ).max ,
372374 np .iinfo ('l' ).max )
373- assert_ ( len (w ) == 1 )
375+ assert len (w ) == 1
374376 desired = np .iinfo ('l' ).max
375377 np .testing .assert_equal (actual , desired )
376378
@@ -396,7 +398,7 @@ def test_randomdist_random_sample(randomdist):
396398 desired = np .array ([[0.9838694715872407 , 0.01914266962558031 ],
397399 [0.1767608025111258 , 0.7096642763353884 ],
398400 [0.518550637178123 , 0.9878093663137406 ]])
399- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
401+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
400402
401403
402404def test_randomdist_choice_uniform_replace (randomdist ):
@@ -461,29 +463,29 @@ def test_choice_exceptions():
461463def test_choice_return_shape ():
462464 p = [0.1 , 0.9 ]
463465 # Check scalar
464- assert_ ( np .isscalar (rnd .choice (2 , replace = True ) ))
465- assert_ ( np .isscalar (rnd .choice (2 , replace = False ) ))
466- assert_ ( np .isscalar (rnd .choice (2 , replace = True , p = p ) ))
467- assert_ ( np .isscalar (rnd .choice (2 , replace = False , p = p ) ))
468- assert_ ( np .isscalar (rnd .choice ([1 , 2 ], replace = True ) ))
469- assert_ ( rnd .choice ([None ], replace = True ) is None )
466+ assert np .isscalar (rnd .choice (2 , replace = True ))
467+ assert np .isscalar (rnd .choice (2 , replace = False ))
468+ assert np .isscalar (rnd .choice (2 , replace = True , p = p ))
469+ assert np .isscalar (rnd .choice (2 , replace = False , p = p ))
470+ assert np .isscalar (rnd .choice ([1 , 2 ], replace = True ))
471+ assert rnd .choice ([None ], replace = True ) is None
470472 a = np .array ([1 , 2 ])
471473 arr = np .empty (1 , dtype = object )
472474 arr [0 ] = a
473- assert_ ( rnd .choice (arr , replace = True ) is a )
475+ assert rnd .choice (arr , replace = True ) is a
474476
475477 # Check 0-d array
476478 s = tuple ()
477- assert_ ( not np .isscalar (rnd .choice (2 , s , replace = True ) ))
478- assert_ ( not np .isscalar (rnd .choice (2 , s , replace = False ) ))
479- assert_ ( not np .isscalar (rnd .choice (2 , s , replace = True , p = p ) ))
480- assert_ ( not np .isscalar (rnd .choice (2 , s , replace = False , p = p ) ))
481- assert_ ( not np .isscalar (rnd .choice ([1 , 2 ], s , replace = True ) ))
482- assert_ ( rnd .choice ([None ], s , replace = True ).ndim == 0 )
479+ assert not np .isscalar (rnd .choice (2 , s , replace = True ))
480+ assert not np .isscalar (rnd .choice (2 , s , replace = False ))
481+ assert not np .isscalar (rnd .choice (2 , s , replace = True , p = p ))
482+ assert not np .isscalar (rnd .choice (2 , s , replace = False , p = p ))
483+ assert not np .isscalar (rnd .choice ([1 , 2 ], s , replace = True ))
484+ assert rnd .choice ([None ], s , replace = True ).ndim == 0
483485 a = np .array ([1 , 2 ])
484486 arr = np .empty (1 , dtype = object )
485487 arr [0 ] = a
486- assert_ ( rnd .choice (arr , s , replace = True ).item () is a )
488+ assert rnd .choice (arr , s , replace = True ).item () is a
487489
488490 # Check multi dimensional array
489491 s = (2 , 3 )
@@ -548,7 +550,7 @@ def test_randomdist_beta(randomdist):
548550 [[0.9856952034381025 , 4.35869375658114e-08 ],
549551 [0.0014230232791189966 , 1.4981856288121975e-06 ],
550552 [1.426135763875603e-06 , 4.5801786040477326e-07 ]])
551- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
553+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
552554
553555
554556def test_randomdist_binomial (randomdist ):
@@ -564,7 +566,7 @@ def test_randomdist_chisquare(randomdist):
564566 desired = np .array ([[50.955833609920589 , 50.133178918244099 ],
565567 [61.513615847062013 , 50.757127871422448 ],
566568 [52.79816819717081 , 49.973023331993552 ]])
567- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
569+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
568570
569571
570572def test_randomdist_dirichlet (randomdist ):
@@ -577,7 +579,7 @@ def test_randomdist_dirichlet(randomdist):
577579 [0.5452378139016114 , 0.45476218609838875 ]],
578580 [[0.6498494402738553 , 0.3501505597261446 ],
579581 [0.5622024400324822 , 0.43779755996751785 ]]])
580- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
582+ np .testing .assert_allclose (actual , desired , atol = 4e-10 , rtol = 4e- 10 )
581583
582584
583585def test_dirichlet_size ():
@@ -599,7 +601,7 @@ def test_randomdist_exponential(randomdist):
599601 desired = np .array ([[0.01826877748252199 , 4.4439855151117005 ],
600602 [1.9468048583654507 , 0.38528493864979607 ],
601603 [0.7377565464231758 , 0.013779117663987912 ]])
602- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
604+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
603605
604606
605607def test_randomdist_f (randomdist ):
@@ -608,7 +610,7 @@ def test_randomdist_f(randomdist):
608610 desired = np .array ([[1.325076177478387 , 0.8670927327120197 ],
609611 [2.1190792007836827 , 0.9095296301824258 ],
610612 [1.4953697422236187 , 0.9547125618834837 ]])
611- np .testing .assert_array_almost_equal (actual , desired , decimal = 9 )
613+ np .testing .assert_allclose (actual , desired , atol = 1e-8 , rtol = 1e- 9 )
612614
613615
614616def test_randomdist_gamma (randomdist ):
@@ -617,7 +619,7 @@ def test_randomdist_gamma(randomdist):
617619 desired = np .array ([[15.073510060334929 , 14.525495858042685 ],
618620 [22.73897210140115 , 14.94044782480266 ],
619621 [16.327929995271095 , 14.419692564592896 ]])
620- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
622+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
621623
622624
623625def test_randomdsit_geometric (randomdist ):
@@ -633,7 +635,7 @@ def test_randomdist_gumbel(randomdist):
633635 desired = np .array ([[- 8.114386462751979 , 2.873840411460178 ],
634636 [1.2231161758452016 , - 2.0168070493213532 ],
635637 [- 0.7175455966332102 , - 8.678464904504784 ]])
636- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
638+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
637639
638640
639641def test_randomdist_hypergeometric (randomdist ):
@@ -667,7 +669,7 @@ def test_randomdist_laplace(randomdist):
667669 desired = np .array ([[0.15598087210935016 , - 3.3424589282252994 ],
668670 [- 1.189978401356375 , 3.0607925598732253 ],
669671 [0.0030946589024587745 , 3.14795824463997 ]])
670- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
672+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
671673
672674
673675def test_randomdist_logistic (randomdist ):
@@ -676,7 +678,7 @@ def test_randomdist_logistic(randomdist):
676678 desired = np .array ([[8.345015961402696 , - 7.749557532940552 ],
677679 [- 2.9534419690278444 , 1.910964962531448 ],
678680 [0.2719300361499433 , 8.913100396613983 ]])
679- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
681+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
680682
681683
682684def test_randomdist_lognormal (randomdist ):
@@ -685,13 +687,13 @@ def test_randomdist_lognormal(randomdist):
685687 desired = np .array ([[81.92291750917155 , 0.01795087229603931 ],
686688 [0.1769118704670423 , 3.415299544410577 ],
687689 [1.2417099625339398 , 102.0631392685238 ]])
688- np .testing .assert_array_almost_equal (actual , desired , decimal = 6 )
690+ np .testing .assert_allclose (actual , desired , atol = 1e-6 , rtol = 1e-10 )
689691 actual = rnd .lognormal (mean = .123456789 , sigma = 2.0 , size = (3 ,2 ),
690692 method = 'Box-Muller2' )
691693 desired = np .array ([[0.2585388231094821 , 0.43734953048924663 ],
692694 [26.050836228611697 , 26.76266237820882 ],
693695 [0.24216420175675096 , 0.2481945765083541 ]])
694- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
696+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
695697
696698
697699def test_randomdist_logseries (randomdist ):
@@ -726,12 +728,12 @@ def test_randomdist_multivariate_normal(randomdist):
726728 [1.001190462507746 , 10.0 ]],
727729 [[- 1.74157261455869 , 10.0 ],
728730 [1.0400952859037553 , 10.0 ]]])
729- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
731+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
730732
731733 # Check for default size, was raising deprecation warning
732734 actual = rnd .multivariate_normal (mean , cov )
733735 desired = np .array ([1.0579899448949994 , 10.0 ])
734- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
736+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
735737
736738 # Check that non positive-semidefinite covariance raises warning
737739 mean = [0 , 0 ]
@@ -752,7 +754,7 @@ def test_randomdist_multinormal_cholesky(randomdist):
752754 [- 0.6146263106001378 , 9.893801873973892 ]],
753755 [[1.691753328795276 , 10.797627196240155 ],
754756 [- 0.647341237129921 , 9.626899489691816 ]]])
755- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
757+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
756758
757759
758760def test_randomdist_negative_binomial (randomdist ):
@@ -768,13 +770,13 @@ def test_randomdist_noncentral_chisquare(randomdist):
768770 desired = np .array ([[5.871334619375055 , 8.756238913383225 ],
769771 [17.29576535176833 , 3.9028417087862177 ],
770772 [5.1315133729432505 , 9.942717979531027 ]])
771- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
773+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
772774
773775 actual = rnd .noncentral_chisquare (df = .5 , nonc = .2 , size = (3 , 2 ))
774776 desired = np .array ([[0.0008971007339949436 , 0.08948578998156566 ],
775777 [0.6721835871997511 , 2.8892645287699352 ],
776778 [5.0858149962761007e-05 , 1.7315797643658821 ]])
777- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
779+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
778780
779781
780782def test_randomdist_noncentral_f (randomdist ):
@@ -784,7 +786,7 @@ def test_randomdist_noncentral_f(randomdist):
784786 desired = np .array ([[0.2216297348371284 , 0.7632696724492449 ],
785787 [98.67664232828238 , 0.9500319825372799 ],
786788 [0.3489618249246971 , 1.5035633972571092 ]])
787- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
789+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
788790
789791
790792def test_randomdist_normal (randomdist ):
@@ -793,21 +795,21 @@ def test_randomdist_normal(randomdist):
793795 desired = np .array ([[4.405778774782659 , - 4.020116569348963 ],
794796 [- 1.732103577371005 , 1.2282652034983546 ],
795797 [0.21648943171034918 , 4.625591634211608 ]])
796- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
798+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
797799
798800 rnd .seed (randomdist .seed , brng = randomdist .brng )
799801 actual = rnd .normal (loc = .123456789 , scale = 2.0 , size = (3 , 2 ), method = "BoxMuller" )
800802 desired = np .array ([[0.16673479781277187 , - 3.4809986872165952 ],
801803 [- 0.05193761082535492 , 3.249201213154922 ],
802804 [- 0.11915582299214138 , 3.555636100927892 ]])
803- np .testing .assert_array_almost_equal (actual , desired , decimal = 8 )
805+ np .testing .assert_allclose (actual , desired , atol = 1e-8 , rtol = 1e- 8 )
804806
805807 rnd .seed (randomdist .seed , brng = randomdist .brng )
806808 actual = rnd .normal (loc = .123456789 , scale = 2.0 , size = (3 , 2 ), method = "BoxMuller2" )
807809 desired = np .array ([[0.16673479781277187 , 0.48153966449249175 ],
808810 [- 3.4809986872165952 , - 0.8101190082826486 ],
809811 [- 0.051937610825354905 , 2.4088402362484342 ]])
810- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
812+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e- 7 )
811813
812814
813815def test_randomdist_pareto (randomdist ):
@@ -853,7 +855,7 @@ def test_randomdist_power(randomdist):
853855 desired = np .array ([[0.8765841803224415 , 1.2140041091640163e-14 ],
854856 [8.013574117268635e-07 , 0.06216255187464781 ],
855857 [0.004895628723087296 , 0.9054248959192386 ]])
856- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
858+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
857859
858860
859861def test_randomdist_rayleigh (randomdist ):
@@ -862,7 +864,7 @@ def test_randomdist_rayleigh(randomdist):
862864 desired = np .array ([[1.80344345931194 , 28.127692489122378 ],
863865 [18.6169699930609 , 8.282068232120208 ],
864866 [11.460520015934597 , 1.5662406536967712 ]])
865- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
867+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
866868
867869
868870def test_randomdist_standard_cauchy (randomdist ):
@@ -871,7 +873,7 @@ def test_randomdist_standard_cauchy(randomdist):
871873 desired = np .array ([[19.716487700629912 , - 16.608240276131227 ],
872874 [- 1.6117703817332278 , 0.7739915895826882 ],
873875 [0.058344614106131 , 26.09825325697747 ]])
874- np .testing .assert_array_almost_equal (actual , desired , decimal = 9 )
876+ np .testing .assert_allclose (actual , desired , atol = 1e-9 , rtol = 1e-10 )
875877
876878
877879def test_randomdist_standard_exponential (randomdist ):
@@ -880,7 +882,7 @@ def test_randomdist_standard_exponential(randomdist):
880882 desired = np .array ([[0.016262041554675085 , 3.955835423813157 ],
881883 [1.7329578586126497 , 0.3429632710074738 ],
882884 [0.6567175951781875 , 0.012265548926462446 ]])
883- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
885+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
884886
885887
886888def test_randomdist_standard_gamma (randomdist ):
@@ -889,7 +891,7 @@ def test_randomdist_standard_gamma(randomdist):
889891 desired = np .array ([[2.939330965027084 , 2.799606052259993 ],
890892 [4.988193705918075 , 2.905305108691164 ],
891893 [3.2630929395548147 , 2.772756340265377 ]])
892- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
894+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
893895
894896
895897def test_randomdist_standard_normal (randomdist ):
@@ -898,14 +900,14 @@ def test_randomdist_standard_normal(randomdist):
898900 desired = np .array ([[2.1411609928913298 , - 2.071786679174482 ],
899901 [- 0.9277801831855025 , 0.5524042072491773 ],
900902 [0.04651632135517459 , 2.2510674226058036 ]])
901- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
903+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
902904
903905 rnd .seed (randomdist .seed , brng = randomdist .brng )
904906 actual = rnd .standard_normal (size = (3 , 2 ), method = 'BoxMuller2' )
905907 desired = np .array ([[0.021639004406385935 , 0.17904143774624587 ],
906908 [- 1.8022277381082976 , - 0.4667878986413243 ],
907909 [- 0.08769719991267745 , 1.1426917236242171 ]])
908- np .testing .assert_array_almost_equal (actual , desired , decimal = 7 )
910+ np .testing .assert_allclose (actual , desired , atol = 1e-7 , rtol = 1e-10 )
909911
910912
911913def test_randomdist_standard_t (randomdist ):
@@ -914,7 +916,7 @@ def test_randomdist_standard_t(randomdist):
914916 desired = np .array ([[- 0.783927044239963 , 0.04762883516531178 ],
915917 [0.7624597987725193 , - 1.8045540288955506 ],
916918 [- 1.2657694296239195 , 0.307870906117017 ]])
917- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
919+ np .testing .assert_allclose (actual , desired , atol = 5e-10 , rtol = 5e- 10 )
918920
919921
920922def test_randomdist_triangular (randomdist ):
@@ -924,7 +926,7 @@ def test_randomdist_triangular(randomdist):
924926 desired = np .array ([[18.764540652669638 , 6.340166306695037 ],
925927 [8.827752689522429 , 13.65605077739865 ],
926928 [11.732872979633328 , 18.970392754850423 ]])
927- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
929+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
928930
929931
930932def test_randomdist_uniform (randomdist ):
@@ -933,7 +935,7 @@ def test_randomdist_uniform(randomdist):
933935 desired = np .array ([[10.38982478047721 , 1.408218254214153 ],
934936 [2.8756430713785814 , 7.836974412682466 ],
935937 [6.057706432128325 , 10.426505200380925 ]])
936- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
938+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
937939
938940
939941def test_uniform_range_bounds ():
@@ -957,7 +959,7 @@ def test_randomdist_vonmises(randomdist):
957959 desired = np .array ([[1.1027657269593822 , 1.2539311427727782 ],
958960 [2.0281801137277764 , 1.3262040229028056 ],
959961 [0.9510301598100863 , 2.0284972823322818 ]])
960- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
962+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
961963
962964
963965def test_randomdist_vonmises_small (randomdist ):
@@ -975,7 +977,7 @@ def test_randomdist_wald(randomdist):
975977 [2.756850184899666 , 2.005347850108636 ],
976978 [1.179918636588408 , 0.20928649815442452 ]
977979 ])
978- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
980+ np .testing .assert_allclose (actual , desired , atol = 1e-10 , rtol = 1e- 10 )
979981
980982
981983def test_randomdist_weibull (randomdist ):
@@ -984,7 +986,7 @@ def test_randomdist_weibull(randomdist):
984986 desired = np .array ([[0.035129404330214734 , 3.058859465984936 ],
985987 [1.5636393343788513 , 0.4189406773709585 ],
986988 [0.710439924774508 , 0.02793103204502023 ]])
987- np .testing .assert_array_almost_equal (actual , desired , decimal = 10 )
989+ np .testing .assert_allclose (actual , desired , atol = 1e- 10 )
988990
989991
990992def test_randomdist_zipf (randomdist ):
@@ -1018,7 +1020,7 @@ def _check_function(seed_list, function, sz):
10181020
10191021 # these platforms change x87 fpu precision mode in threads
10201022 if (np .intp ().dtype .itemsize == 4 and sys .platform == "win32" ):
1021- np .testing .assert_array_almost_equal (out1 , out2 )
1023+ np .testing .assert_allclose (out1 , out2 )
10221024 else :
10231025 np .testing .assert_array_equal (out1 , out2 )
10241026
0 commit comments