@@ -217,8 +217,8 @@ def test_logp(self):
217
217
class TestGrassiaIIGeometric :
218
218
class TestRandomVariable (BaseTestDistributionRandom ):
219
219
pymc_dist = GrassiaIIGeometric
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 ]}
220
+ pymc_dist_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : [1.0 , 2.0 , 3 .0 ]}
221
+ expected_rv_op_params = {"r" : 0.5 , "alpha" : 2.0 , "time_covariate_vector" : [1.0 , 2.0 , 3 .0 ]}
222
222
tests_to_run = [
223
223
"check_pymc_params_match_rv_op" ,
224
224
"check_rv_size" ,
@@ -250,7 +250,7 @@ def test_random_edge_cases(self):
250
250
# Test with small r and large alpha values
251
251
r_vals = [0.1 , 0.5 ]
252
252
alpha_vals = [5.0 , 10.0 ]
253
- time_cov_vals = [[0.0 ], [1 .0 ]]
253
+ time_cov_vals = [[0.0 , 1.0 , 2.0 ], [5.0 , 10.0 , 15 .0 ]]
254
254
255
255
for r in r_vals :
256
256
for alpha in alpha_vals :
@@ -266,34 +266,13 @@ def test_random_edge_cases(self):
266
266
assert np .mean (draws ) > 0
267
267
assert np .var (draws ) > 0
268
268
269
- def test_random_none_covariates (self ):
270
- """Test random sampling with None time_covariate_vector"""
271
- r_vals = [0.5 , 1.0 , 2.0 ]
272
- alpha_vals = [0.5 , 1.0 , 2.0 ]
273
-
274
- for r in r_vals :
275
- for alpha in alpha_vals :
276
- dist = self .pymc_dist .dist (
277
- r = r ,
278
- alpha = alpha ,
279
- time_covariate_vector = [0.0 ], # Changed from None to avoid zip issues
280
- size = 1000 ,
281
- )
282
- draws = dist .eval ()
283
-
284
- # Check basic properties
285
- assert np .all (draws > 0 )
286
- assert np .all (draws .astype (int ) == draws )
287
- assert np .mean (draws ) > 0
288
- assert np .var (draws ) > 0
289
-
290
269
@pytest .mark .parametrize (
291
270
"r,alpha,time_covariate_vector" ,
292
271
[
293
- (0.5 , 1.0 , None ),
272
+ (0.5 , 1.0 , [[ 0.0 ], [ 0.0 ], [ 0.0 ]] ),
294
273
(1.0 , 2.0 , [1.0 ]),
295
274
(2.0 , 0.5 , [[1.0 ], [2.0 ]]),
296
- ([5.0 ], [1.0 ], None ),
275
+ ([5.0 ], [1.0 ], [ 0.0 , 0.0 , 0.0 ] ),
297
276
],
298
277
)
299
278
def test_random_moments (self , r , alpha , time_covariate_vector ):
@@ -311,7 +290,7 @@ def test_logp(self):
311
290
# Create PyTensor variables with explicit values to ensure proper initialization
312
291
r = pt .as_tensor_variable (1.0 )
313
292
alpha = pt .as_tensor_variable (2.0 )
314
- time_covariate_vector = pt .as_tensor_variable ([0.5 , 1.0 ])
293
+ time_covariate_vector = pt .as_tensor_variable ([[ 0.5 , 1.0 , 1.5 ], [ 0.0 , 0.0 , 0.0 ] ])
315
294
value = pt .vector ("value" , dtype = "int64" )
316
295
317
296
# Create the distribution with the PyTensor variables
@@ -335,16 +314,16 @@ def test_logp(self):
335
314
def test_logcdf (self ):
336
315
# test logcdf matches log sums across parameter values
337
316
check_selfconsistency_discrete_logcdf (
338
- GrassiaIIGeometric , NatBig , {"r" : Rplus , "alpha" : Rplus , "time_covariate_vector" : Rplus }
317
+ GrassiaIIGeometric , NatBig , {"r" : Rplus , "alpha" : Rplus , "time_covariate_vector" : I }
339
318
)
340
319
341
320
@pytest .mark .parametrize (
342
321
"r, alpha, time_covariate_vector, size, expected_shape" ,
343
322
[
344
- (1.0 , 1.0 , None , None , ()), # Scalar output with no covariates
323
+ (1.0 , 1.0 , [ 0.0 , 0.0 , 0.0 ], None , ()), # Scalar output
345
324
([1.0 , 2.0 ], 1.0 , [0.0 ], None , (2 ,)), # Vector output from r
346
325
(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
326
+ (1.0 , 1.0 , [[ 1.0 , 2.0 ], [ 3.0 , 4.0 ]], None , (2 , )), # Vector output from time covariates
348
327
(1.0 , 1.0 , [1.0 , 2.0 ], (3 , 2 ), (3 , 2 )), # Explicit size with time covariates
349
328
],
350
329
)
0 commit comments