Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dpnp/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,26 @@ def is_gpu_device(device=None):
return dev.has_aspect_gpu


def is_intel_numpy():
"""
Return True if Intel NumPy is used during testing.

The check is based on MKL backend name stored in Build Dependencies, where
in case of Intel Numpy there "mkl" is expected at the beginning of the name
for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp").

"""

build_deps = numpy.show_config(mode="dicts")["Build Dependencies"]
blas = build_deps["blas"]
lapack = build_deps["lapack"]

if numpy_version() < "2.0.0":
# numpy 1.26.4 has LAPACK name equals to 'dep140030038112336'
return blas["name"].startswith("mkl")
return all(dep["name"].startswith("mkl") for dep in [blas, lapack])


def is_win_platform():
"""
Return True if a test is running on Windows OS, False otherwise.
Expand Down
7 changes: 4 additions & 3 deletions dpnp/tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
get_integer_float_dtypes,
has_support_aspect16,
has_support_aspect64,
is_intel_numpy,
numpy_version,
)
from .third_party.cupy import testing
Expand Down Expand Up @@ -1751,11 +1752,11 @@ def test_zeros(self, dt):

result = dpnp.spacing(ia)
expected = numpy.spacing(a)
if numpy_version() < "2.0.0":
if is_intel_numpy():
assert_allclose(result, expected)
else:
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. NumPy returns
# positive value (looks as a bug in NumPy), because for any other
# numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. the stock NumPy
# returns positive value (looks as a bug), because for any other
# negative input the NumPy result will be also a negative value.
expected[1] *= -1
assert_allclose(result, expected)
Expand Down
Loading