Skip to content

Commit d3e5136

Browse files
Add dtype checking for inexact dtype in assert_dtype_allclose
1 parent ad90f66 commit d3e5136

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/helper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def assert_dtype_allclose(dpnp_arr, numpy_arr, check_type=True):
1212
Assert DPNP and NumPy array based on maximum dtype resolution of input arrays
1313
for floating and complex types.
1414
For other dtypes the assertion is based on exact matching of the arrays.
15+
When 'check_type' True (default), it asserts equal dtypes for exact types
16+
and either equal dtypes or kinds for inexact types, depending on the 64-bit precision
17+
support of the device on which `dpnp_arr` is created.
1518
1619
"""
1720

@@ -22,6 +25,11 @@ def assert_dtype_allclose(dpnp_arr, numpy_arr, check_type=True):
2225
numpy.finfo(numpy_arr.dtype).resolution,
2326
)
2427
assert_allclose(dpnp_arr.asnumpy(), numpy_arr, atol=tol, rtol=tol)
28+
if check_type:
29+
if has_support_aspect64(dpnp_arr.sycl_device):
30+
assert dpnp_arr.dtype == numpy_arr.dtype
31+
else:
32+
assert dpnp_arr.dtype.kind == numpy_arr.dtype.kind
2533
else:
2634
assert_array_equal(dpnp_arr.asnumpy(), numpy_arr)
2735
if check_type:

0 commit comments

Comments
 (0)