Skip to content

Commit 2027b27

Browse files
Add TestAttributes to test_arraycreation.py
1 parent 25a2c6a commit 2027b27

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

dpnp/tests/test_arraycreation.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,33 @@ 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+
5986
class TestTrace:
6087
@pytest.mark.parametrize("a_sh", [(3, 4), (2, 2, 2)])
6188
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)