Skip to content

Commit 67e9db9

Browse files
aseyboldttwiecki
authored andcommitted
Fix pickleing of NoDistribution
1 parent 569a82e commit 67e9db9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pymc3/distributions/distribution.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ def __init__(self, shape, dtype, testval=None, defaults=(),
132132
self.parent_dist = parent_dist
133133

134134
def __getattr__(self, name):
135-
try:
136-
self.__dict__[name]
137-
except KeyError:
138-
return getattr(self.parent_dist, name)
135+
# Do not use __getstate__ and __setstate__ from parent_dist
136+
# to avoid infinite recursion during unpickling
137+
if name.startswith('__'):
138+
raise AttributeError(
139+
"'NoDistribution' has no attribute '%s'" % name)
140+
return getattr(self.parent_dist, name)
139141

140142
def logp(self, x):
141143
return 0

0 commit comments

Comments
 (0)