Skip to content

Commit 99459d8

Browse files
committed
remove unnecessary floor divide tests
1 parent 7a91fea commit 99459d8

File tree

1 file changed

+1
-149
lines changed

1 file changed

+1
-149
lines changed

dpctl/tests/elementwise/test_floor_divide.py

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@
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.tensor._type_utils import _can_cast
2522
from dpctl.tests.helper import get_queue_or_skip, skip_if_dtype_not_supported
2623

27-
from .utils import (
28-
_compare_dtypes,
29-
_integral_dtypes,
30-
_no_complex_dtypes,
31-
_usm_types,
32-
)
24+
from .utils import _compare_dtypes, _integral_dtypes, _no_complex_dtypes
3325

3426

3527
@pytest.mark.parametrize("op1_dtype", _no_complex_dtypes[1:])
@@ -66,134 +58,6 @@ def test_floor_divide_dtype_matrix(op1_dtype, op2_dtype):
6658
assert (dpt.asnumpy(r) == expected.astype(r.dtype)).all()
6759

6860

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

@@ -263,18 +127,6 @@ def test_floor_divide_special_cases():
263127
np.testing.assert_array_equal(dpt.asnumpy(res), res_np)
264128

265129

266-
@pytest.mark.parametrize("dtype", _no_complex_dtypes[1:])
267-
def test_divide_inplace_python_scalar(dtype):
268-
q = get_queue_or_skip()
269-
skip_if_dtype_not_supported(dtype, q)
270-
X = dpt.zeros((10, 10), dtype=dtype, sycl_queue=q)
271-
dt_kind = X.dtype.kind
272-
if dt_kind in "ui":
273-
X //= int(1)
274-
elif dt_kind == "f":
275-
X //= float(1)
276-
277-
278130
@pytest.mark.parametrize("op1_dtype", _no_complex_dtypes[1:])
279131
@pytest.mark.parametrize("op2_dtype", _no_complex_dtypes[1:])
280132
def test_floor_divide_inplace_dtype_matrix(op1_dtype, op2_dtype):

0 commit comments

Comments
 (0)