Skip to content

Commit 700b0d8

Browse files
author
Luca Citi
committed
Addressed failed tests (with older python/numpy versions)
1 parent 5e7fd29 commit 700b0d8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pytensor/tensor/rewriting/math.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2999,7 +2999,9 @@ def isclose(x, ref, rtol=0, atol=0, num_ulps=10):
29992999
True iff x is a constant close to ref (by default 10 ULPs).
30003000
30013001
"""
3002-
atol = atol + num_ulps * np.spacing(x)
3002+
x = np.asarray(x)
3003+
if np.issubdtype(x.dtype, np.floating):
3004+
atol = atol + num_ulps * np.abs(np.spacing(x.dtype.type(ref)))
30033005
return np.allclose(x, ref, rtol=rtol, atol=atol)
30043006

30053007

tests/tensor/rewriting/test_math.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4299,7 +4299,8 @@ def test_log1msigm_to_softplus(self):
42994299
f(np.random.random((54, 11)).astype(config.floatX))
43004300

43014301
# Test close to 1
4302-
out = log(np.nextafter(1.0, 2.0) - sigmoid(x))
4302+
x_dtype = np.dtype(x.dtype).type
4303+
out = log(np.nextafter(x_dtype(1), x_dtype(2)) - sigmoid(x))
43034304
f = pytensor.function([x], out, mode=self.m)
43044305
topo = f.maker.fgraph.toposort()
43054306
assert len(topo) == 2

0 commit comments

Comments
 (0)