Skip to content

Commit 892f0ae

Browse files
committed
Fix positional arguments Bound RV
1 parent fbe86a4 commit 892f0ae

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pymc3/distributions/bound.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def __init__(self, distribution, lower, upper,
151151
default = None
152152

153153
super().__init__(
154-
distribution=distribution, lower=lower, upper=upper,
155-
transform=transform, default=default, *args, **kwargs)
154+
distribution, lower, upper,
155+
default, *args, transform=transform, **kwargs)
156156

157157

158158
class Bound:
@@ -214,12 +214,13 @@ def __call__(self, name, *args, **kwargs):
214214
'with the cumulative probability function. See '
215215
'pymc3/examples/censored_data.py for an example.')
216216

217+
transform = kwargs.pop('transform', 'infer')
217218
if issubclass(self.distribution, Continuous):
218-
return _ContinuousBounded(name, self.distribution,
219-
self.lower, self.upper, *args, **kwargs)
219+
return _ContinuousBounded(name, self.distribution, self.lower,
220+
self.upper, transform, *args, **kwargs)
220221
elif issubclass(self.distribution, Discrete):
221-
return _DiscreteBounded(name, self.distribution,
222-
self.lower, self.upper, *args, **kwargs)
222+
return _DiscreteBounded(name, self.distribution, self.lower,
223+
self.upper, transform, *args, **kwargs)
223224
else:
224225
raise ValueError(
225226
'Distribution is neither continuous nor discrete.')

pymc3/tests/test_distributions.py

+4
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,10 @@ def test_bound():
12951295
BoundPoisson = Bound(Poisson, upper=6)
12961296
BoundPoisson(name="y", mu=1)
12971297

1298+
with Model():
1299+
BoundNormalNamedArgs = Bound(Normal, upper=6)("y", mu=2., sd=1.)
1300+
BoundNormalPositionalArgs = Bound(Normal, upper=6)("x", 2., 1.)
1301+
12981302

12991303
class TestLatex:
13001304

0 commit comments

Comments
 (0)