47
47
from pymc .tests .distributions .util import assert_moment_is_expected
48
48
from pymc .tests .helpers import select_by_precision
49
49
50
+ # Turn all warnings into errors for this module
51
+ # Ignoring NumPy deprecation warning tracked in https://github.com/pymc-devs/pytensor/issues/146
52
+ pytestmark = pytest .mark .filterwarnings ("error" , "ignore: NumPy will stop allowing conversion" )
53
+
50
54
51
55
class TestRandomWalk :
52
56
def test_dists_types (self ):
@@ -92,6 +96,14 @@ def test_dists_not_registered_check(self):
92
96
):
93
97
RandomWalk ("rw" , init_dist = init_dist , innovation_dist = innovation , steps = 5 )
94
98
99
+ def test_dists_independent_check (self ):
100
+ init_dist = Normal .dist ()
101
+ innovation_dist = Normal .dist (init_dist )
102
+ with pytest .raises (
103
+ ValueError , match = "init_dist and innovation_dist must be completely independent"
104
+ ):
105
+ RandomWalk .dist (init_dist = init_dist , innovation_dist = innovation_dist )
106
+
95
107
@pytest .mark .parametrize (
96
108
"init_dist, innovation_dist, steps, size, shape, "
97
109
"init_dist_size, innovation_dist_size, rw_shape" ,
@@ -423,15 +435,18 @@ def test_mvgaussian_with_chol_cov_rv(self, param):
423
435
"chol_cov" , n = 3 , eta = 2 , sd_dist = sd_dist , compute_corr = True
424
436
)
425
437
# pylint: enable=unpacking-non-sequence
426
- if param == "chol" :
427
- mv = MvGaussianRandomWalk ("mv" , mu , chol = chol , shape = (10 , 7 , 3 ))
428
- elif param == "cov" :
429
- mv = MvGaussianRandomWalk ("mv" , mu , cov = pm .math .dot (chol , chol .T ), shape = (10 , 7 , 3 ))
430
- else :
431
- raise ValueError
438
+ with pytest .warns (UserWarning , match = "Initial distribution not specified" ):
439
+ if param == "chol" :
440
+ mv = MvGaussianRandomWalk ("mv" , mu , chol = chol , shape = (10 , 7 , 3 ))
441
+ elif param == "cov" :
442
+ mv = MvGaussianRandomWalk (
443
+ "mv" , mu , cov = pm .math .dot (chol , chol .T ), shape = (10 , 7 , 3 )
444
+ )
445
+ else :
446
+ raise ValueError
432
447
assert draw (mv , draws = 5 ).shape == (5 , 10 , 7 , 3 )
433
448
434
- @pytest .mark .parametrize ("param" , ["cov " , "chol" , "tau" ])
449
+ @pytest .mark .parametrize ("param" , ["scale " , "chol" , "tau" ])
435
450
def test_mvstudentt (self , param ):
436
451
x = MvStudentTRandomWalk .dist (
437
452
nu = 4 ,
@@ -853,7 +868,13 @@ def sde_fn(x, k, d, s):
853
868
with Model () as t0 :
854
869
init_dist = pm .Normal .dist (0 , 10 , shape = (batch_size ,))
855
870
y = EulerMaruyama (
856
- "y" , dt = 0.02 , sde_fn = sde_fn , sde_pars = sde_pars , init_dist = init_dist , ** kwargs
871
+ "y" ,
872
+ dt = 0.02 ,
873
+ sde_fn = sde_fn ,
874
+ sde_pars = sde_pars ,
875
+ init_dist = init_dist ,
876
+ initval = "prior" ,
877
+ ** kwargs ,
857
878
)
858
879
859
880
y_eval = draw (y , draws = 2 , random_seed = numpy_rng )
@@ -873,6 +894,7 @@ def sde_fn(x, k, d, s):
873
894
sde_fn = sde_fn ,
874
895
sde_pars = sde_pars_slice ,
875
896
init_dist = init_dist ,
897
+ initval = "prior" ,
876
898
** kwargs ,
877
899
)
878
900
0 commit comments