Skip to content

Commit 5a85c7b

Browse files
committed
Correct the expected result in spacing test
1 parent 8c1b28e commit 5a85c7b

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

dpnp/tests/helper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,22 @@ def is_gpu_device(device=None):
397397
return dev.has_aspect_gpu
398398

399399

400+
def is_intel_numpy():
401+
"""
402+
Return True if Intel NumPy is used during testing.
403+
404+
The check is based on MKL backend name stored in Build Dependencies, where
405+
in case of Intel Numpy there "mkl-dynamic" is expected to be a part of the
406+
name for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp").
407+
408+
"""
409+
410+
build_deps = numpy.show_config(mode="dicts")["Build Dependencies"]
411+
blas = build_deps["blas"]
412+
lapack = build_deps["lapack"]
413+
return all("mkl-dynamic" in dep["name"] for dep in [blas, lapack])
414+
415+
400416
def is_win_platform():
401417
"""
402418
Return True if a test is running on Windows OS, False otherwise.

dpnp/tests/test_mathematical.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
get_integer_float_dtypes,
3333
has_support_aspect16,
3434
has_support_aspect64,
35+
is_intel_numpy,
3536
numpy_version,
3637
)
3738
from .third_party.cupy import testing
@@ -1756,11 +1757,11 @@ def test_zeros(self, dt):
17561757

17571758
result = dpnp.spacing(ia)
17581759
expected = numpy.spacing(a)
1759-
if numpy_version() < "2.0.0":
1760+
if is_intel_numpy():
17601761
assert_allclose(result, expected)
17611762
else:
1762-
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. NumPy returns
1763-
# positive value (looks as a bug in NumPy), because for any other
1763+
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. the stock NumPy
1764+
# returns positive value (looks as a bug), because for any other
17641765
# negative input the NumPy result will be also a negative value.
17651766
expected[1] *= -1
17661767
assert_allclose(result, expected)

0 commit comments

Comments
 (0)