Skip to content

Commit 5716806

Browse files
fonnesbecktwiecki
authored andcommitted
Renamed ConstantDist to Constant
1 parent 0d5f292 commit 5716806

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

pymc3/distributions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .discrete import Poisson
3232
from .discrete import NegativeBinomial
3333
from .discrete import ConstantDist
34+
from .discrete import Constant
3435
from .discrete import ZeroInflatedPoisson
3536
from .discrete import ZeroInflatedNegativeBinomial
3637
from .discrete import DiscreteUniform
@@ -94,6 +95,7 @@
9495
'Poisson',
9596
'NegativeBinomial',
9697
'ConstantDist',
98+
'Constant',
9799
'ZeroInflatedPoisson',
98100
'ZeroInflatedNegativeBinomial',
99101
'DiscreteUniform',

pymc3/distributions/discrete.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .distribution import Discrete, draw_values, generate_samples
1010

1111
__all__ = ['Binomial', 'BetaBinomial', 'Bernoulli', 'Poisson',
12-
'NegativeBinomial', 'ConstantDist', 'ZeroInflatedPoisson',
12+
'NegativeBinomial', 'ConstantDist', 'Constant', 'ZeroInflatedPoisson',
1313
'ZeroInflatedNegativeBinomial', 'DiscreteUniform', 'Geometric',
1414
'Categorical']
1515

@@ -413,7 +413,7 @@ def logp(self, value):
413413
sumto1)
414414

415415

416-
class ConstantDist(Discrete):
416+
class Constant(Discrete):
417417
"""
418418
Constant log-likelihood.
419419
@@ -424,7 +424,7 @@ class ConstantDist(Discrete):
424424
"""
425425

426426
def __init__(self, c, *args, **kwargs):
427-
super(ConstantDist, self).__init__(*args, **kwargs)
427+
super(Constant, self).__init__(*args, **kwargs)
428428
self.mean = self.median = self.mode = self.c = c
429429

430430
def random(self, point=None, size=None, repeat=None):
@@ -441,6 +441,11 @@ def logp(self, value):
441441
c = self.c
442442
return bound(0, tt.eq(value, c))
443443

444+
def ConstantDist(*args, **kwargs):
445+
warnings.warn("ConstantDist has been deprecated. In future, use Constant instead.",
446+
DeprecationWarning)
447+
return Constant(*args, **kwargs)
448+
444449

445450
class ZeroInflatedPoisson(Discrete):
446451
R"""

pymc3/tests/test_distributions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..blocking import DictToVarBijection, DictToArrayBijection, ArrayOrdering
88
from ..distributions import (DensityDist, Categorical, Multinomial, VonMises, Dirichlet,
99
MvStudentT, MvNormal, ZeroInflatedPoisson,
10-
ZeroInflatedNegativeBinomial, ConstantDist, Poisson, Bernoulli, Beta,
10+
ZeroInflatedNegativeBinomial, ConstantDist, Constant, Poisson, Bernoulli, Beta,
1111
BetaBinomial, HalfStudentT, StudentT, Weibull, Pareto, InverseGamma,
1212
Gamma, Cauchy, HalfCauchy, Lognormal, Laplace, NegativeBinomial,
1313
Geometric, Exponential, ExGaussian, Normal, Flat, LKJCorr, Wald,
@@ -479,7 +479,7 @@ def test_poisson(self):
479479
lambda value, mu: sp.poisson.logpmf(value, mu))
480480

481481
def test_constantdist(self):
482-
self.pymc3_matches_scipy(ConstantDist, I, {'c': I},
482+
self.pymc3_matches_scipy(Constant, I, {'c': I},
483483
lambda value, c: np.log(c == value))
484484

485485
def test_zeroinflatedpoisson(self):

pymc3/tests/test_distributions_random.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ class TestNegativeBinomial(BaseTestCases.BaseTestCase):
281281
params = {'mu': 1., 'alpha': 1.}
282282

283283

284-
class TestConstantDist(BaseTestCases.BaseTestCase):
285-
distribution = pm.ConstantDist
284+
class TestConstant(BaseTestCases.BaseTestCase):
285+
distribution = pm.Constant
286286
params = {'c': 3}
287287

288288

@@ -471,7 +471,7 @@ def ref_rand(size, p):
471471
def test_constant_dist(self):
472472
def ref_rand(size, c):
473473
return c * np.ones(size, dtype=int)
474-
pymc3_random_discrete(pm.ConstantDist, {'c': I}, ref_rand=ref_rand)
474+
pymc3_random_discrete(pm.Constant, {'c': I}, ref_rand=ref_rand)
475475

476476
def test_mv_normal(self):
477477
def ref_rand(size, mu, cov):

0 commit comments

Comments
 (0)