@@ -158,7 +158,7 @@ def setup_method(self, *args, **kwargs):
158
158
self .model = pm .Model ()
159
159
160
160
def get_random_variable (self , shape , with_vector_params = False , name = None ):
161
- """ Creates a RandomVariable of the parametrized distribution. """
161
+ """Creates a RandomVariable of the parametrized distribution."""
162
162
if with_vector_params :
163
163
params = {
164
164
key : value * np .ones (self .shape , dtype = np .dtype (type (value )))
@@ -187,7 +187,7 @@ def get_random_variable(self, shape, with_vector_params=False, name=None):
187
187
188
188
@staticmethod
189
189
def sample_random_variable (random_variable , size ):
190
- """ Draws samples from a RandomVariable using its .random() method. """
190
+ """Draws samples from a RandomVariable using its .random() method."""
191
191
if size is None :
192
192
return random_variable .eval ()
193
193
else :
@@ -196,7 +196,7 @@ def sample_random_variable(random_variable, size):
196
196
@pytest .mark .parametrize ("size" , [None , (), 1 , (1 ,), 5 , (4 , 5 )], ids = str )
197
197
@pytest .mark .parametrize ("shape" , [None , ()], ids = str )
198
198
def test_scalar_distribution_shape (self , shape , size ):
199
- """ Draws samples of different [size] from a scalar [shape] RV. """
199
+ """Draws samples of different [size] from a scalar [shape] RV."""
200
200
rv = self .get_random_variable (shape )
201
201
exp_shape = self .default_shape if shape is None else tuple (np .atleast_1d (shape ))
202
202
exp_size = self .default_size if size is None else tuple (np .atleast_1d (size ))
@@ -216,7 +216,7 @@ def test_scalar_distribution_shape(self, shape, size):
216
216
"shape" , [None , (), (1 ,), (1 , 1 ), (1 , 2 ), (10 , 11 , 1 ), (9 , 10 , 2 )], ids = str
217
217
)
218
218
def test_scalar_sample_shape (self , shape , size ):
219
- """ Draws samples of scalar [size] from a [shape] RV. """
219
+ """Draws samples of scalar [size] from a [shape] RV."""
220
220
rv = self .get_random_variable (shape )
221
221
exp_shape = self .default_shape if shape is None else tuple (np .atleast_1d (shape ))
222
222
exp_size = self .default_size if size is None else tuple (np .atleast_1d (size ))
@@ -289,12 +289,6 @@ class TestExGaussian(BaseTestCases.BaseTestCase):
289
289
params = {"mu" : 0.0 , "sigma" : 1.0 , "nu" : 1.0 }
290
290
291
291
292
- @pytest .mark .xfail (reason = "This distribution has not been refactored for v4" )
293
- class TestLogitNormal (BaseTestCases .BaseTestCase ):
294
- distribution = pm .LogitNormal
295
- params = {"mu" : 0.0 , "sigma" : 1.0 }
296
-
297
-
298
292
@pytest .mark .xfail (reason = "This distribution has not been refactored for v4" )
299
293
class TestZeroInflatedNegativeBinomial (BaseTestCases .BaseTestCase ):
300
294
distribution = pm .ZeroInflatedNegativeBinomial
@@ -575,6 +569,32 @@ class TestNormal(BaseTestDistribution):
575
569
]
576
570
577
571
572
+ class TestLogitNormal (BaseTestDistribution ):
573
+ def logit_normal_rng_fn (self , rng , size , loc , scale ):
574
+ return expit (st .norm .rvs (loc = loc , scale = scale , size = size , random_state = rng ))
575
+
576
+ pymc_dist = pm .LogitNormal
577
+ pymc_dist_params = {"mu" : 5.0 , "sigma" : 10.0 }
578
+ expected_rv_op_params = {"mu" : 5.0 , "sigma" : 10.0 }
579
+ reference_dist_params = {"loc" : 5.0 , "scale" : 10.0 }
580
+ reference_dist = lambda self : functools .partial (
581
+ self .logit_normal_rng_fn , rng = self .get_random_state ()
582
+ )
583
+ tests_to_run = [
584
+ "check_pymc_params_match_rv_op" ,
585
+ "check_pymc_draws_match_reference" ,
586
+ "check_rv_size" ,
587
+ ]
588
+
589
+
590
+ class TestLogitNormalTau (BaseTestDistribution ):
591
+ pymc_dist = pm .LogitNormal
592
+ tau , sigma = get_tau_sigma (tau = 25.0 )
593
+ pymc_dist_params = {"mu" : 1.0 , "tau" : tau }
594
+ expected_rv_op_params = {"mu" : 1.0 , "sigma" : sigma }
595
+ tests_to_run = ["check_pymc_params_match_rv_op" ]
596
+
597
+
578
598
class TestNormalTau (BaseTestDistribution ):
579
599
pymc_dist = pm .Normal
580
600
tau , sigma = get_tau_sigma (tau = 25.0 )
@@ -1443,7 +1463,6 @@ def test_dirichlet_multinomial_dist_ShapeError(self, n, a, shape, expectation):
1443
1463
with expectation :
1444
1464
m .random ()
1445
1465
1446
- @pytest .mark .xfail (reason = "This distribution has not been refactored for v4" )
1447
1466
def test_logitnormal (self ):
1448
1467
def ref_rand (size , mu , sigma ):
1449
1468
return expit (st .norm .rvs (loc = mu , scale = sigma , size = size ))
0 commit comments