Skip to content

Commit 84a52e4

Browse files
Apply remarks
1 parent 6675ca8 commit 84a52e4

File tree

4 files changed

+50
-48
lines changed

4 files changed

+50
-48
lines changed

dpnp/tests/test_arraycreation.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,6 @@ def test_error(self):
5656
assert_raises(TypeError, dpnp.array, x, ndmin=3.0)
5757

5858

59-
class TestAttributes:
60-
def setup_method(self):
61-
self.one = dpnp.arange(10)
62-
self.two = dpnp.arange(20).reshape(4, 5)
63-
self.three = dpnp.arange(60).reshape(2, 5, 6)
64-
65-
def test_attributes(self):
66-
assert_equal(self.one.shape, (10,))
67-
assert_equal(self.two.shape, (4, 5))
68-
assert_equal(self.three.shape, (2, 5, 6))
69-
self.three.shape = (10, 3, 2)
70-
assert_equal(self.three.shape, (10, 3, 2))
71-
self.three.shape = (2, 5, 6)
72-
assert_equal(self.one.strides, (self.one.itemsize / self.one.itemsize,))
73-
num = self.two.itemsize / self.two.itemsize
74-
assert_equal(self.two.strides, (5 * num, num))
75-
num = self.three.itemsize / self.three.itemsize
76-
assert_equal(self.three.strides, (30 * num, 6 * num, num))
77-
assert_equal(self.one.ndim, 1)
78-
assert_equal(self.two.ndim, 2)
79-
assert_equal(self.three.ndim, 3)
80-
num = self.two.itemsize
81-
assert_equal(self.two.size, 20)
82-
assert_equal(self.two.nbytes, 20 * num)
83-
assert_equal(self.two.itemsize, self.two.dtype.itemsize)
84-
85-
8659
class TestTrace:
8760
@pytest.mark.parametrize("a_sh", [(3, 4), (2, 2, 2)])
8861
@pytest.mark.parametrize(
@@ -241,20 +214,6 @@ def test_arange(start, stop, step, dtype):
241214
assert_array_equal(exp_array, res_array)
242215

243216

244-
@pytest.mark.parametrize(
245-
"arr",
246-
[
247-
numpy.array([1]),
248-
dpnp.array([1]),
249-
[1],
250-
],
251-
ids=["numpy", "dpnp", "list"],
252-
)
253-
def test_create_from_usm_ndarray_error(arr):
254-
with pytest.raises(TypeError):
255-
dpnp.dpnp_array.dpnp_array._create_from_usm_ndarray(arr)
256-
257-
258217
@pytest.mark.parametrize("func", ["diag", "diagflat"])
259218
@pytest.mark.parametrize("k", [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6])
260219
@pytest.mark.parametrize(
@@ -384,8 +343,7 @@ def test_identity(n, dtype):
384343

385344
def test_identity_error():
386345
# negative dimensions
387-
with pytest.raises(ValueError):
388-
_ = dpnp.identity(-5)
346+
assert_raises(ValueError, dpnp.identity, -5)
389347

390348

391349
@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False))

dpnp/tests/test_fft.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,7 @@ def test_ihfft_bool(self, n, norm):
673673
def test_ihfft_error(self):
674674
a = dpnp.ones(11)
675675
# incorrect norm
676-
with pytest.raises(ValueError):
677-
_ = dpnp.fft.ihfft(a, norm="backwards")
676+
assert_raises(ValueError, dpnp.fft.ihfft, a, norm="backwards")
678677

679678

680679
class TestIrfft:

dpnp/tests/test_flat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
import pytest
3-
from numpy.testing import assert_array_equal
3+
from numpy.testing import assert_array_equal, assert_raises
44

55
import dpnp
66

@@ -28,8 +28,7 @@ def test_flat_iteration(self):
2828
assert dp_val == np_val
2929

3030
def test_init_error(self):
31-
with pytest.raises(TypeError):
32-
_ = dpnp.flatiter([1, 2, 3])
31+
assert_raises(TypeError, dpnp.flatiter, [1, 2, 3])
3332

3433
def test_flat_key_error(self):
3534
a_dp = dpnp.array(42)

dpnp/tests/test_ndarray.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from numpy.testing import (
55
assert_allclose,
66
assert_array_equal,
7+
assert_equal,
78
assert_raises_regex,
89
)
910

@@ -40,6 +41,51 @@ def test_astype_subok_error():
4041
x.astype("i4", subok=False)
4142

4243

44+
class TestAttributes:
45+
def setup_method(self):
46+
self.one = dpnp.arange(10)
47+
self.two = dpnp.arange(20).reshape(4, 5)
48+
self.three = dpnp.arange(60).reshape(2, 5, 6)
49+
50+
def test_attributes(self):
51+
assert_equal(self.one.shape, (10,))
52+
assert_equal(self.two.shape, (4, 5))
53+
assert_equal(self.three.shape, (2, 5, 6))
54+
55+
self.three.shape = (10, 3, 2)
56+
assert_equal(self.three.shape, (10, 3, 2))
57+
self.three.shape = (2, 5, 6)
58+
59+
assert_equal(self.one.strides, (self.one.itemsize / self.one.itemsize,))
60+
num = self.two.itemsize / self.two.itemsize
61+
assert_equal(self.two.strides, (5 * num, num))
62+
num = self.three.itemsize / self.three.itemsize
63+
assert_equal(self.three.strides, (30 * num, 6 * num, num))
64+
65+
assert_equal(self.one.ndim, 1)
66+
assert_equal(self.two.ndim, 2)
67+
assert_equal(self.three.ndim, 3)
68+
69+
num = self.two.itemsize
70+
assert_equal(self.two.size, 20)
71+
assert_equal(self.two.nbytes, 20 * num)
72+
assert_equal(self.two.itemsize, self.two.dtype.itemsize)
73+
74+
75+
@pytest.mark.parametrize(
76+
"arr",
77+
[
78+
numpy.array([1]),
79+
dpnp.array([1]),
80+
[1],
81+
],
82+
ids=["numpy", "dpnp", "list"],
83+
)
84+
def test_create_from_usm_ndarray_error(arr):
85+
with pytest.raises(TypeError):
86+
dpnp.dpnp_array.dpnp_array._create_from_usm_ndarray(arr)
87+
88+
4389
@pytest.mark.parametrize("arr_dtype", get_all_dtypes())
4490
@pytest.mark.parametrize(
4591
"arr",

0 commit comments

Comments
 (0)