We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6ae9f3d + cda4574 commit 0df3becCopy full SHA for 0df3bec
dpctl/tests/elementwise/test_abs.py
@@ -84,18 +84,19 @@ def test_abs_order(dtype):
84
skip_if_dtype_not_supported(dtype, q)
85
86
arg_dt = np.dtype(dtype)
87
+ exp_dt = np.abs(np.ones(tuple(), dtype=arg_dt)).dtype
88
input_shape = (10, 10, 10, 10)
89
X = dpt.empty(input_shape, dtype=arg_dt, sycl_queue=q)
90
X[..., 0::2] = 1
91
X[..., 1::2] = 0
92
- for ord in ["C", "F", "A", "K"]:
93
- for perms in itertools.permutations(range(4)):
94
- U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
+ for perms in itertools.permutations(range(4)):
+ U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
95
+ expected_Y = np.ones(U.shape, dtype=exp_dt)
96
+ expected_Y[..., 1::2] = 0
97
+ expected_Y = np.transpose(expected_Y, perms)
98
+ for ord in ["C", "F", "A", "K"]:
99
Y = dpt.abs(U, order=ord)
- expected_Y = np.ones(Y.shape, dtype=Y.dtype)
- expected_Y[..., 1::2] = 0
- expected_Y = np.transpose(expected_Y, perms)
100
assert np.allclose(dpt.asnumpy(Y), expected_Y)
101
102
dpctl/tests/elementwise/test_complex.py
@@ -120,7 +120,7 @@ def test_complex_order(np_call, dpt_call, dtype):
120
expected_Y = np_call(dpt.asnumpy(U))
121
for ord in ["C", "F", "A", "K"]:
122
Y = dpt_call(U, order=ord)
123
- assert np.allclose(dpt.asnumpy(Y), expected_Y)
+ assert_allclose(dpt.asnumpy(Y), expected_Y)
124
125
126
@pytest.mark.parametrize("dtype", ["c8", "c16"])
dpctl/tests/elementwise/test_exp2.py
@@ -103,11 +103,11 @@ def test_exp2_order(dtype):
103
X[..., 0::2] = 1 / 4
104
X[..., 1::2] = 1 / 2
105
106
107
108
+ expected_Y = np.exp2(dpt.asnumpy(U))
109
110
Y = dpt.exp2(U, order=ord)
- expected_Y = np.exp2(dpt.asnumpy(U))
111
tol = 8 * max(
112
dpt.finfo(Y.dtype).resolution,
113
np.finfo(expected_Y.dtype).resolution,
dpctl/tests/elementwise/test_expm1.py
@@ -103,11 +103,11 @@ def test_expm1_order(dtype):
X[..., 0::2] = 1 / 50
X[..., 1::2] = 1 / 25
+ expected_Y = np.expm1(dpt.asnumpy(U))
Y = dpt.expm1(U, order=ord)
- expected_Y = np.expm1(dpt.asnumpy(U))
dpctl/tests/elementwise/test_isfinite.py
@@ -18,6 +18,7 @@
18
19
import numpy as np
20
import pytest
21
+from numpy.testing import assert_allclose
22
23
import dpctl.tensor as dpt
24
from dpctl.tests.helper import get_queue_or_skip, skip_if_dtype_not_supported
@@ -90,9 +91,9 @@ def test_isfinite_order(dtype):
X = dpt.ones(input_shape, dtype=arg_dt, sycl_queue=q)
- U = dpt.permute_dims(X[::2, ::-1, ::-1, ::5], perms)
+ U = dpt.permute_dims(X[::2, ::-1, ::-1, ::5], perms)
+ expected_Y = np.full(U.shape, fill_value=True, dtype=dpt.bool)
Y = dpt.isfinite(U, order=ord)
- expected_Y = np.full(Y.shape, True, dtype=Y.dtype)
dpctl/tests/elementwise/test_isinf.py
@@ -84,9 +85,9 @@ def test_isinf_order(dtype):
+ expected_Y = np.full(U.shape, fill_value=False, dtype=dpt.bool)
Y = dpt.isinf(U, order=ord)
- expected_Y = np.full(Y.shape, False, dtype=Y.dtype)
dpctl/tests/elementwise/test_isnan.py
@@ -90,9 +90,9 @@ def test_isnan_order(dtype):
Y = dpt.isnan(U, order=ord)
dpctl/tests/elementwise/test_log.py
@@ -103,11 +103,11 @@ def test_log_order(dtype):
X[..., 0::2] = 4 * dpt.e
X[..., 1::2] = 10 * dpt.e
+ expected_Y = np.log(dpt.asnumpy(U))
Y = dpt.log(U, order=ord)
- expected_Y = np.log(dpt.asnumpy(U))
dpctl/tests/elementwise/test_log10.py
@@ -107,11 +107,11 @@ def test_log_order(dtype):
+ expected_Y = np.log10(dpt.asnumpy(U))
114
Y = dpt.log10(U, order=ord)
- expected_Y = np.log10(dpt.asnumpy(U))
115
116
117
dpctl/tests/elementwise/test_log1p.py
@@ -103,11 +103,11 @@ def test_log1p_order(dtype):
X[..., 0::2] = dpt.e / 1000
X[..., 1::2] = dpt.e / 100
+ expected_Y = np.log1p(dpt.asnumpy(U))
Y = dpt.log1p(U, order=ord)
- expected_Y = np.log1p(dpt.asnumpy(U))
0 commit comments