Skip to content

Commit 80bf8aa

Browse files
committed
remove redundant tests for positive and negative
1 parent 1592ed1 commit 80bf8aa

File tree

2 files changed

+2
-86
lines changed

2 files changed

+2
-86
lines changed

dpctl/tests/elementwise/test_negative.py

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

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

2220
import dpctl.tensor as dpt
2321
from dpctl.tests.helper import get_queue_or_skip, skip_if_dtype_not_supported
2422

25-
from .utils import _all_dtypes, _usm_types
23+
from .utils import _all_dtypes
2624

2725

2826
@pytest.mark.parametrize("dtype", _all_dtypes[1:])
@@ -44,43 +42,3 @@ def test_negative_bool():
4442
x = dpt.ones(64, dtype="?")
4543
with pytest.raises(ValueError):
4644
dpt.negative(x)
47-
48-
49-
@pytest.mark.parametrize("usm_type", _usm_types)
50-
def test_negative_usm_type(usm_type):
51-
q = get_queue_or_skip()
52-
53-
arg_dt = np.dtype("i4")
54-
input_shape = (10, 10, 10, 10)
55-
X = dpt.empty(input_shape, dtype=arg_dt, usm_type=usm_type, sycl_queue=q)
56-
X[..., 0::2] = 1
57-
X[..., 1::2] = 0
58-
59-
Y = dpt.negative(X)
60-
assert Y.usm_type == X.usm_type
61-
assert Y.sycl_queue == X.sycl_queue
62-
assert Y.flags.c_contiguous
63-
64-
expected_Y = np.negative(dpt.asnumpy(X))
65-
assert np.allclose(dpt.asnumpy(Y), expected_Y)
66-
67-
68-
@pytest.mark.parametrize("dtype", _all_dtypes[1:])
69-
def test_negative_order(dtype):
70-
q = get_queue_or_skip()
71-
skip_if_dtype_not_supported(dtype, q)
72-
73-
arg_dt = np.dtype(dtype)
74-
input_shape = (10, 10, 10, 10)
75-
X = dpt.empty(input_shape, dtype=arg_dt, sycl_queue=q)
76-
X[..., 0::2] = 1
77-
X[..., 1::2] = 0
78-
79-
for perms in itertools.permutations(range(4)):
80-
U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
81-
expected_Y = np.negative(np.ones(U.shape, dtype=U.dtype))
82-
expected_Y[..., 1::2] = 0
83-
expected_Y = np.transpose(expected_Y, perms)
84-
for ord in ["C", "F", "A", "K"]:
85-
Y = dpt.negative(U, order=ord)
86-
assert np.allclose(dpt.asnumpy(Y), expected_Y)

dpctl/tests/elementwise/test_positive.py

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

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

2220
import dpctl.tensor as dpt
2321
from dpctl.tests.helper import get_queue_or_skip, skip_if_dtype_not_supported
2422

25-
from .utils import _all_dtypes, _usm_types
23+
from .utils import _all_dtypes
2624

2725

2826
@pytest.mark.parametrize("dtype", _all_dtypes[1:])
@@ -37,43 +35,3 @@ def test_positive_out_type(dtype):
3735
r = dpt.empty_like(X, dtype=arg_dt)
3836
dpt.positive(X, out=r)
3937
assert np.allclose(dpt.asnumpy(r), dpt.asnumpy(dpt.positive(X)))
40-
41-
42-
@pytest.mark.parametrize("usm_type", _usm_types)
43-
def test_positive_usm_type(usm_type):
44-
q = get_queue_or_skip()
45-
46-
arg_dt = np.dtype("i4")
47-
input_shape = (10, 10, 10, 10)
48-
X = dpt.empty(input_shape, dtype=arg_dt, usm_type=usm_type, sycl_queue=q)
49-
X[..., 0::2] = 1
50-
X[..., 1::2] = 0
51-
52-
Y = dpt.positive(X)
53-
assert Y.usm_type == X.usm_type
54-
assert Y.sycl_queue == X.sycl_queue
55-
assert Y.flags.c_contiguous
56-
57-
expected_Y = dpt.asnumpy(X)
58-
assert np.allclose(dpt.asnumpy(Y), expected_Y)
59-
60-
61-
@pytest.mark.parametrize("dtype", _all_dtypes[1:])
62-
def test_positive_order(dtype):
63-
q = get_queue_or_skip()
64-
skip_if_dtype_not_supported(dtype, q)
65-
66-
arg_dt = np.dtype(dtype)
67-
input_shape = (10, 10, 10, 10)
68-
X = dpt.empty(input_shape, dtype=arg_dt, sycl_queue=q)
69-
X[..., 0::2] = 1
70-
X[..., 1::2] = 0
71-
72-
for perms in itertools.permutations(range(4)):
73-
U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
74-
expected_Y = np.ones(U.shape, dtype=U.dtype)
75-
expected_Y[..., 1::2] = 0
76-
expected_Y = np.transpose(expected_Y, perms)
77-
for ord in ["C", "F", "A", "K"]:
78-
Y = dpt.positive(U, order=ord)
79-
assert np.allclose(dpt.asnumpy(Y), expected_Y)

0 commit comments

Comments
 (0)