Skip to content

Commit ccf4783

Browse files
committed
Tune a tolerance in ercx consistency tests
1 parent 34ba78d commit ccf4783

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

dpnp/tests/test_special.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def test_complex(self, func, dt):
6565

6666
class TestConsistency:
6767

68+
tol = 8 * dpnp.finfo(dpnp.default_float_type()).resolution
69+
6870
def _check_variant_func(self, func, other_func, rtol, atol=0):
6971
# TODO: replace with dpnp.random.RandomState, once pareto is added
7072
rng = numpy.random.RandomState(1234)
@@ -77,19 +79,22 @@ def _check_variant_func(self, func, other_func, rtol, atol=0):
7779
mask = dpnp.isfinite(res)
7880
a = a[mask]
7981

80-
assert dpnp.allclose(func(a), res[mask], rtol=rtol, atol=atol)
82+
x, y = func(a), res[mask]
83+
if not dpnp.allclose(x, y, rtol=rtol, atol=atol):
84+
# calling numpy testing func, because it's more verbose
85+
assert_allclose(x.asnumpy(), y.asnumpy(), rtol=rtol, atol=atol)
8186

8287
def test_erfc(self):
8388
self._check_variant_func(
8489
dpnp.special.erfc,
8590
lambda z: 1 - dpnp.special.erf(z),
86-
rtol=1e-12,
87-
atol=1e-14,
91+
rtol=self.tol,
92+
atol=self.tol,
8893
)
8994

9095
def test_erfcx(self):
9196
self._check_variant_func(
9297
dpnp.special.erfcx,
9398
lambda z: dpnp.exp(z * z) * dpnp.special.erfc(z),
94-
rtol=1e-12,
99+
rtol=10 * self.tol,
95100
)

0 commit comments

Comments
 (0)