Skip to content

Commit c0773b7

Browse files
aloctavodiatwiecki
authored andcommitted
small fix to vonmises distribution and add test for circular transformation
1 parent b2be720 commit c0773b7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pymc3/distributions/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def backward(self, y):
260260
return tt.arctan2(tt.sin(y), tt.cos(y))
261261

262262
def forward(self, x):
263-
return x
263+
return tt.as_tensor_variable(x)
264264

265265
def jacobian_det(self, x):
266266
return 0

pymc3/tests/test_transforms.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
import theano
44
import theano.tensor as tt
5-
from .test_distributions import Simplex, Rplusbig, Rminusbig, Unit, R, Vector, MultiSimplex
5+
from .test_distributions import Simplex, Rplusbig, Rminusbig, Unit, R, Vector, MultiSimplex, Circ
66

77
from .checks import close_to
88
from ..theanof import jacobian
@@ -144,3 +144,15 @@ def test_interval():
144144
vals = get_values(trans)
145145
close_to(vals > a, True, tol)
146146
close_to(vals < b, True, tol)
147+
148+
149+
def test_circular():
150+
trans = tr.circular
151+
check_transform_identity(trans, Circ)
152+
check_jacobian_det(trans, Circ)
153+
154+
vals = get_values(trans)
155+
close_to(vals > -np.pi, True, tol)
156+
close_to(vals < np.pi, True, tol)
157+
158+
assert isinstance(trans.forward(1), tt.TensorConstant)

0 commit comments

Comments
 (0)