Skip to content

Commit 06b577e

Browse files
committed
remove unnecessary hypot tests
1 parent 97296f1 commit 06b577e

File tree

1 file changed

+1
-137
lines changed

1 file changed

+1
-137
lines changed

dpctl/tests/elementwise/test_hypot.py

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import ctypes
18-
1917
import numpy as np
2018
import pytest
2119

22-
import dpctl
2320
import dpctl.tensor as dpt
2421
from dpctl.tests.helper import get_queue_or_skip, skip_if_dtype_not_supported
2522

26-
from .utils import _compare_dtypes, _no_complex_dtypes, _usm_types
23+
from .utils import _compare_dtypes, _no_complex_dtypes
2724

2825

2926
@pytest.mark.parametrize("op1_dtype", _no_complex_dtypes[1:])
@@ -58,136 +55,3 @@ def test_hypot_dtype_matrix(op1_dtype, op2_dtype):
5855
assert _compare_dtypes(r.dtype, expected.dtype, sycl_queue=q)
5956
assert r.shape == ar3.shape
6057
assert (dpt.asnumpy(r) == expected.astype(r.dtype)).all()
61-
62-
63-
@pytest.mark.parametrize("op1_usm_type", _usm_types)
64-
@pytest.mark.parametrize("op2_usm_type", _usm_types)
65-
def test_hypot_usm_type_matrix(op1_usm_type, op2_usm_type):
66-
get_queue_or_skip()
67-
68-
sz = 128
69-
ar1 = dpt.ones(sz, dtype="i4", usm_type=op1_usm_type)
70-
ar2 = dpt.ones_like(ar1, dtype="i4", usm_type=op2_usm_type)
71-
72-
r = dpt.hypot(ar1, ar2)
73-
assert isinstance(r, dpt.usm_ndarray)
74-
expected_usm_type = dpctl.utils.get_coerced_usm_type(
75-
(op1_usm_type, op2_usm_type)
76-
)
77-
assert r.usm_type == expected_usm_type
78-
79-
80-
def test_hypot_order():
81-
get_queue_or_skip()
82-
83-
ar1 = dpt.ones((20, 20), dtype="i4", order="C")
84-
ar2 = dpt.ones((20, 20), dtype="i4", order="C")
85-
r1 = dpt.hypot(ar1, ar2, order="C")
86-
assert r1.flags.c_contiguous
87-
r2 = dpt.hypot(ar1, ar2, order="F")
88-
assert r2.flags.f_contiguous
89-
r3 = dpt.hypot(ar1, ar2, order="A")
90-
assert r3.flags.c_contiguous
91-
r4 = dpt.hypot(ar1, ar2, order="K")
92-
assert r4.flags.c_contiguous
93-
94-
ar1 = dpt.ones((20, 20), dtype="i4", order="F")
95-
ar2 = dpt.ones((20, 20), dtype="i4", order="F")
96-
r1 = dpt.hypot(ar1, ar2, order="C")
97-
assert r1.flags.c_contiguous
98-
r2 = dpt.hypot(ar1, ar2, order="F")
99-
assert r2.flags.f_contiguous
100-
r3 = dpt.hypot(ar1, ar2, order="A")
101-
assert r3.flags.f_contiguous
102-
r4 = dpt.hypot(ar1, ar2, order="K")
103-
assert r4.flags.f_contiguous
104-
105-
ar1 = dpt.ones((40, 40), dtype="i4", order="C")[:20, ::-2]
106-
ar2 = dpt.ones((40, 40), dtype="i4", order="C")[:20, ::-2]
107-
r4 = dpt.hypot(ar1, ar2, order="K")
108-
assert r4.strides == (20, -1)
109-
110-
ar1 = dpt.ones((40, 40), dtype="i4", order="C")[:20, ::-2].mT
111-
ar2 = dpt.ones((40, 40), dtype="i4", order="C")[:20, ::-2].mT
112-
r4 = dpt.hypot(ar1, ar2, order="K")
113-
assert r4.strides == (-1, 20)
114-
115-
116-
def test_hypot_broadcasting():
117-
get_queue_or_skip()
118-
119-
m = dpt.ones((100, 5), dtype="i4")
120-
v = dpt.arange(1, 6, dtype="i4")
121-
122-
r = dpt.hypot(m, v)
123-
124-
expected = np.hypot(
125-
np.ones((100, 5), dtype="i4"), np.arange(1, 6, dtype="i4")
126-
)
127-
tol = 8 * np.finfo(r.dtype).resolution
128-
assert np.allclose(
129-
dpt.asnumpy(r), expected.astype(r.dtype), atol=tol, rtol=tol
130-
)
131-
132-
r2 = dpt.hypot(v, m)
133-
expected2 = np.hypot(
134-
np.arange(1, 6, dtype="i4"), np.ones((100, 5), dtype="i4")
135-
)
136-
assert np.allclose(
137-
dpt.asnumpy(r2), expected2.astype(r2.dtype), atol=tol, rtol=tol
138-
)
139-
140-
141-
@pytest.mark.parametrize("arr_dt", _no_complex_dtypes[1:])
142-
def test_hypot_python_scalar(arr_dt):
143-
q = get_queue_or_skip()
144-
skip_if_dtype_not_supported(arr_dt, q)
145-
146-
X = dpt.ones((10, 10), dtype=arr_dt, sycl_queue=q)
147-
py_ones = (
148-
bool(1),
149-
int(1),
150-
float(1),
151-
np.float32(1),
152-
ctypes.c_int(1),
153-
)
154-
for sc in py_ones:
155-
R = dpt.hypot(X, sc)
156-
assert isinstance(R, dpt.usm_ndarray)
157-
R = dpt.hypot(sc, X)
158-
assert isinstance(R, dpt.usm_ndarray)
159-
160-
161-
class MockArray:
162-
def __init__(self, arr):
163-
self.data_ = arr
164-
165-
@property
166-
def __sycl_usm_array_interface__(self):
167-
return self.data_.__sycl_usm_array_interface__
168-
169-
170-
def test_hypot_mock_array():
171-
get_queue_or_skip()
172-
a = dpt.arange(10)
173-
b = dpt.ones(10)
174-
c = MockArray(b)
175-
r = dpt.hypot(a, c)
176-
assert isinstance(r, dpt.usm_ndarray)
177-
178-
179-
def test_hypot_canary_mock_array():
180-
get_queue_or_skip()
181-
a = dpt.arange(10)
182-
183-
class Canary:
184-
def __init__(self):
185-
pass
186-
187-
@property
188-
def __sycl_usm_array_interface__(self):
189-
return None
190-
191-
c = Canary()
192-
with pytest.raises(ValueError):
193-
dpt.hypot(a, c)

0 commit comments

Comments
 (0)