Skip to content

Commit 9e97a25

Browse files
committed
Correct the expected result in spacing test
1 parent e41ff80 commit 9e97a25

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
@@ -414,6 +414,22 @@ def is_gpu_device(device=None):
414414
return dev.has_aspect_gpu
415415

416416

417+
def is_intel_numpy():
418+
"""
419+
Return True if Intel NumPy is used during testing.
420+
421+
The check is based on MKL backend name stored in Build Dependencies, where
422+
in case of Intel Numpy there "mkl-dynamic" is expected to be a part of the
423+
name for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp").
424+
425+
"""
426+
427+
build_deps = numpy.show_config(mode="dicts")["Build Dependencies"]
428+
blas = build_deps["blas"]
429+
lapack = build_deps["lapack"]
430+
return all("mkl-dynamic" in dep["name"] for dep in [blas, lapack])
431+
432+
417433
def is_win_platform():
418434
"""
419435
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
@@ -1751,11 +1752,11 @@ def test_zeros(self, dt):
17511752

17521753
result = dpnp.spacing(ia)
17531754
expected = numpy.spacing(a)
1754-
if numpy_version() < "2.0.0":
1755+
if is_intel_numpy():
17551756
assert_allclose(result, expected)
17561757
else:
1757-
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. NumPy returns
1758-
# positive value (looks as a bug in NumPy), because for any other
1758+
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. the stock NumPy
1759+
# returns positive value (looks as a bug), because for any other
17591760
# negative input the NumPy result will be also a negative value.
17601761
expected[1] *= -1
17611762
assert_allclose(result, expected)

0 commit comments

Comments
 (0)