24
24
BaseTestDistributionRandom ,
25
25
Domain ,
26
26
I ,
27
+ NatBig ,
27
28
Rplus ,
28
29
assert_support_point_is_expected ,
29
30
check_logp ,
@@ -216,8 +217,8 @@ def test_logp(self):
216
217
class TestGrassiaIIGeometric :
217
218
class TestRandomVariable (BaseTestDistributionRandom ):
218
219
pymc_dist = GrassiaIIGeometric
219
- pymc_dist_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : 0.0 }
220
- expected_rv_op_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : 0.0 }
220
+ pymc_dist_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : [ 0.0 ] }
221
+ expected_rv_op_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : [ 0.0 ] }
221
222
tests_to_run = [
222
223
"check_pymc_params_match_rv_op" ,
223
224
"check_rv_size" ,
@@ -228,7 +229,7 @@ def test_random_basic_properties(self):
228
229
# Test with standard parameter values
229
230
r_vals = [0.5 , 1.0 , 2.0 ]
230
231
alpha_vals = [0.5 , 1.0 , 2.0 ]
231
- time_cov_vals = [- 1.0 , 1.0 , 2.0 ]
232
+ time_cov_vals = [[ 0.0 ], [ 1.0 ], [ 2.0 ] ]
232
233
233
234
for r in r_vals :
234
235
for alpha in alpha_vals :
@@ -275,7 +276,7 @@ def test_random_none_covariates(self):
275
276
dist = self .pymc_dist .dist (
276
277
r = r ,
277
278
alpha = alpha ,
278
- time_covariate_vector = 0.0 , # Changed from None to avoid zip issues
279
+ time_covariate_vector = [ 0.0 ] , # Changed from None to avoid zip issues
279
280
size = 1000 ,
280
281
)
281
282
draws = dist .eval ()
@@ -289,10 +290,10 @@ def test_random_none_covariates(self):
289
290
@pytest .mark .parametrize (
290
291
"r,alpha,time_covariate_vector" ,
291
292
[
292
- (0.5 , 1.0 , 0.0 ),
293
- (1.0 , 2.0 , 1.0 ),
294
- (2.0 , 0.5 , - 1.0 ),
295
- (5.0 , 1.0 , 0.0 ), # Changed from None to avoid zip issues
293
+ (0.5 , 1.0 , None ),
294
+ (1.0 , 2.0 , [ 1.0 ] ),
295
+ (2.0 , 0.5 , [[ 1.0 ], [ 2.0 ]] ),
296
+ ([ 5.0 ], [ 1.0 ], None ),
296
297
],
297
298
)
298
299
def test_random_moments (self , r , alpha , time_covariate_vector ):
@@ -306,11 +307,11 @@ def test_random_moments(self, r, alpha, time_covariate_vector):
306
307
assert np .mean (draws ) > 0
307
308
assert np .var (draws ) > 0
308
309
309
- def test_logp_basic (self ):
310
+ def test_logp (self ):
310
311
# Create PyTensor variables with explicit values to ensure proper initialization
311
312
r = pt .as_tensor_variable (1.0 )
312
313
alpha = pt .as_tensor_variable (2.0 )
313
- time_covariate_vector = pt .as_tensor_variable (0.5 )
314
+ time_covariate_vector = pt .as_tensor_variable ([ 0.5 , 1.0 ] )
314
315
value = pt .vector ("value" , dtype = "int64" )
315
316
316
317
# Create the distribution with the PyTensor variables
@@ -334,17 +335,17 @@ def test_logp_basic(self):
334
335
def test_logcdf (self ):
335
336
# test logcdf matches log sums across parameter values
336
337
check_selfconsistency_discrete_logcdf (
337
- GrassiaIIGeometric , I , {"r" : Rplus , "alpha" : Rplus , "time_covariate_vector" : I }
338
+ GrassiaIIGeometric , NatBig , {"r" : Rplus , "alpha" : Rplus , "time_covariate_vector" : Rplus }
338
339
)
339
340
340
341
@pytest .mark .parametrize (
341
342
"r, alpha, time_covariate_vector, size, expected_shape" ,
342
343
[
343
- (1.0 , 1.0 , 0.0 , None , ()), # Scalar output with no covariates (0.0 instead of None)
344
- ([1.0 , 2.0 ], 1.0 , 0.0 , None , (2 ,)), # Vector output from r
345
- (1.0 , [1.0 , 2.0 ], 0.0 , None , (2 ,)), # Vector output from alpha
346
- (1.0 , 1.0 , [1.0 , 2.0 ], None , (2 , )), # Vector output from time covariates
347
- (1.0 , 1.0 , 1.0 , (3 , 2 ), (3 , 2 )), # Explicit size with scalar time covariates
344
+ (1.0 , 1.0 , None , None , ()), # Scalar output with no covariates
345
+ ([1.0 , 2.0 ], 1.0 , [ 0.0 ] , None , (2 ,)), # Vector output from r
346
+ (1.0 , [1.0 , 2.0 ], [ 0.0 ] , None , (2 ,)), # Vector output from alpha
347
+ (1.0 , 1.0 , [1.0 , 2.0 ], None , ()), # Vector output from time covariates
348
+ (1.0 , 1.0 , [ 1.0 , 2.0 ], (3 , 2 ), (3 , 2 )), # Explicit size with time covariates
348
349
],
349
350
)
350
351
def test_support_point (self , r , alpha , time_covariate_vector , size , expected_shape ):
0 commit comments