Skip to content

Commit 6184bc0

Browse files
michaelosthegetwiecki
authored andcommitted
initial workaround to fix #2510
logp fails if value is not a TensorVariable. Also the SplitWrapper (self.interp_op) does not do broadcasting. This workaround is probably not the fastest though.
1 parent 3457ad2 commit 6184bc0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pymc3/distributions/continuous.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,4 +2004,11 @@ def random(self, point=None, size=None, repeat=None):
20042004
size=size)
20052005

20062006
def logp(self, value):
2007-
return tt.log(self.interp_op(value) / self.Z)
2007+
# TODO: this implementation is suboptimal
2008+
# the SplineWrapper should get proper broadcasting behavior
2009+
value = tt.as_tensor_variable(value)
2010+
if hasattr(value, "__iter__"):
2011+
iv = tt.stack([self.interp_op(v) for v in value])
2012+
else:
2013+
iv = self.interp_op(value)
2014+
return tt.log(iv / self.Z)

0 commit comments

Comments
 (0)