Skip to content

Commit edcaf75

Browse files
committed
Fixed float32 precision errors
1 parent 5da42f7 commit edcaf75

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pymc3/tests/test_distributions_timeseries.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import numpy as np
88
import pytest
9+
from .helpers import select_by_precision
910

1011
pytestmark = pytest.mark.usefixtures('seeded_test')
1112

@@ -92,7 +93,8 @@ def test_GARCH11():
9293
z = Normal('z', mu=0, sigma=vol, shape=data.shape)
9394
garch_like = t['y'].logp({'z':data, 'y': data})
9495
reg_like = t['z'].logp({'z':data, 'y': data})
95-
np.testing.assert_allclose(garch_like, reg_like)
96+
decimal = select_by_precision(float64=7, float32=4)
97+
np.testing.assert_allclose(garch_like, reg_like, 10**(-decimal))
9698

9799

98100

pymc3/tests/test_minibatches.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,14 @@ def test_multidim_scaling(self):
232232
with pm.Model() as model5:
233233
Normal('n', observed=[[1]], total_size=[2, Ellipsis, 2])
234234
p5 = theano.function([], model5.logpt)
235-
assert p0() == p1() == p2() == p3() == p4() == p5()
235+
_p0 = p0()
236+
assert (
237+
np.allclose(_p0, p1()) and
238+
np.allclose(_p0, p2()) and
239+
np.allclose(_p0, p3()) and
240+
np.allclose(_p0, p4()) and
241+
np.allclose(_p0, p5())
242+
)
236243

237244
def test_common_errors(self):
238245
with pm.Model():

0 commit comments

Comments
 (0)