diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 32f4d392fb5a..1f5365220595 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -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. diff --git a/dpnp/tests/test_mathematical.py b/dpnp/tests/test_mathematical.py index 3aef83d317d9..bd15b4ca7281 100644 --- a/dpnp/tests/test_mathematical.py +++ b/dpnp/tests/test_mathematical.py @@ -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 @@ -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)