25
25
26
26
from pymc .ode import DifferentialEquation
27
27
from pymc .ode .utils import augment_system
28
+ from pymc .tests .helpers import fast_unstable_sampling_mode
28
29
29
30
IS_FLOAT32 = aesara .config .floatX == "float32"
30
31
IS_WINDOWS = sys .platform == "win32"
@@ -291,11 +292,13 @@ def system(y, t, p):
291
292
sigma = pm .HalfCauchy ("sigma" , 1 )
292
293
forward = ode_model (theta = [alpha ], y0 = [y0 ])
293
294
y = pm .LogNormal ("y" , mu = pm .math .log (forward ), sd = sigma , observed = yobs )
294
- idata = pm .sample (100 , tune = 0 , chains = 1 )
295
295
296
- assert idata .posterior ["alpha" ].shape == (1 , 100 )
297
- assert idata .posterior ["y0" ].shape == (1 , 100 )
298
- assert idata .posterior ["sigma" ].shape == (1 , 100 )
296
+ with aesara .config .change_flags (mode = fast_unstable_sampling_mode ):
297
+ idata = pm .sample (50 , tune = 0 , chains = 1 )
298
+
299
+ assert idata .posterior ["alpha" ].shape == (1 , 50 )
300
+ assert idata .posterior ["y0" ].shape == (1 , 50 )
301
+ assert idata .posterior ["sigma" ].shape == (1 , 50 )
299
302
300
303
def test_scalar_ode_2_param (self ):
301
304
"""Test running model for a scalar ODE with 2 parameters"""
@@ -321,12 +324,13 @@ def system(y, t, p):
321
324
forward = ode_model (theta = [alpha , beta ], y0 = [y0 ])
322
325
y = pm .LogNormal ("y" , mu = pm .math .log (forward ), sd = sigma , observed = yobs )
323
326
324
- idata = pm .sample (100 , tune = 0 , chains = 1 )
327
+ with aesara .config .change_flags (mode = fast_unstable_sampling_mode ):
328
+ idata = pm .sample (50 , tune = 0 , chains = 1 )
325
329
326
- assert idata .posterior ["alpha" ].shape == (1 , 100 )
327
- assert idata .posterior ["beta" ].shape == (1 , 100 )
328
- assert idata .posterior ["y0" ].shape == (1 , 100 )
329
- assert idata .posterior ["sigma" ].shape == (1 , 100 )
330
+ assert idata .posterior ["alpha" ].shape == (1 , 50 )
331
+ assert idata .posterior ["beta" ].shape == (1 , 50 )
332
+ assert idata .posterior ["y0" ].shape == (1 , 50 )
333
+ assert idata .posterior ["sigma" ].shape == (1 , 50 )
330
334
331
335
def test_vector_ode_1_param (self ):
332
336
"""Test running model for a vector ODE with 1 parameter"""
@@ -362,10 +366,11 @@ def system(y, t, p):
362
366
forward = ode_model (theta = [R ], y0 = [0.99 , 0.01 ])
363
367
y = pm .LogNormal ("y" , mu = pm .math .log (forward ), sd = sigma , observed = yobs )
364
368
365
- idata = pm .sample (100 , tune = 0 , chains = 1 )
369
+ with aesara .config .change_flags (mode = fast_unstable_sampling_mode ):
370
+ idata = pm .sample (50 , tune = 0 , chains = 1 )
366
371
367
- assert idata .posterior ["R" ].shape == (1 , 100 )
368
- assert idata .posterior ["sigma" ].shape == (1 , 100 , 2 )
372
+ assert idata .posterior ["R" ].shape == (1 , 50 )
373
+ assert idata .posterior ["sigma" ].shape == (1 , 50 , 2 )
369
374
370
375
def test_vector_ode_2_param (self ):
371
376
"""Test running model for a vector ODE with 2 parameters"""
@@ -402,8 +407,9 @@ def system(y, t, p):
402
407
forward = ode_model (theta = [beta , gamma ], y0 = [0.99 , 0.01 ])
403
408
y = pm .LogNormal ("y" , mu = pm .math .log (forward ), sd = sigma , observed = yobs )
404
409
405
- idata = pm .sample (100 , tune = 0 , chains = 1 )
410
+ with aesara .config .change_flags (mode = fast_unstable_sampling_mode ):
411
+ idata = pm .sample (50 , tune = 0 , chains = 1 )
406
412
407
- assert idata .posterior ["beta" ].shape == (1 , 100 )
408
- assert idata .posterior ["gamma" ].shape == (1 , 100 )
409
- assert idata .posterior ["sigma" ].shape == (1 , 100 , 2 )
413
+ assert idata .posterior ["beta" ].shape == (1 , 50 )
414
+ assert idata .posterior ["gamma" ].shape == (1 , 50 )
415
+ assert idata .posterior ["sigma" ].shape == (1 , 50 , 2 )
0 commit comments