Skip to content

Commit 3f300e9

Browse files
aloctavodiatwiecki
authored andcommitted
change circular transform from ElemwiseTransform to Transform. add circular domain for vonmises tests (#1520)
1 parent ebf26d5 commit 3f300e9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pymc3/distributions/transforms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def jacobian_det(self, y_):
240240
t_stick_breaking = lambda eps: StickBreaking(eps)
241241

242242

243-
class Circular(ElemwiseTransform):
243+
class Circular(Transform):
244244
"""Transforms a linear space into a circular one.
245245
"""
246246
name = "circular"
@@ -250,5 +250,8 @@ def backward(self, y):
250250

251251
def forward(self, x):
252252
return x
253+
254+
def jacobian_det(self, x):
255+
return 0
253256

254257
circular = Circular()

pymc3/tests/test_distributions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def product(domains, n_samples=-1):
9090
Rminusbig = Domain([-inf, -2, -1.5, -1, -.99, -.9, -.5, -0.01, 0])
9191
Unit = Domain([0, .001, .1, .5, .75, .99, 1])
9292

93+
Circ = Domain([-np.pi -2.1, -1, -.01, .0, .01, 1, 2.1, np.pi])
94+
9395
Runif = Domain([-1, -.4, 0, .4, 1])
9496
Rdunif = Domain([-10, 0, 10.])
9597
Rplusunif = Domain([0, .5, inf])
@@ -678,8 +680,9 @@ def check_ex_gaussian(self, value, mu, sigma, nu, logp):
678680
pt = {'eg': value}
679681
assert_almost_equal(model.fastlogp(pt), logp, decimal=6, err_msg=str(pt))
680682

683+
681684
def test_vonmises(self):
682-
self.pymc3_matches_scipy(VonMises, R, {'mu': R, 'kappa': Rplus},
685+
self.pymc3_matches_scipy(VonMises, R, {'mu': Circ, 'kappa': Rplus},
683686
lambda value, mu, kappa: sp.vonmises.logpdf(value, kappa, loc=mu))
684687

685688
def test_multidimensional_beta_construction(self):

0 commit comments

Comments
 (0)