Skip to content

Commit b63907a

Browse files
Adds a test to modify writable flag
1 parent 0008a7f commit b63907a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_allocate_usm_ndarray(shape, usm_type):
5757

5858

5959
def test_usm_ndarray_flags():
60+
get_queue_or_skip()
6061
assert dpt.usm_ndarray((5,), dtype="i4").flags.fc
6162
assert dpt.usm_ndarray((5, 2), dtype="i4").flags.c_contiguous
6263
assert dpt.usm_ndarray((5, 2), dtype="i4", order="F").flags.f_contiguous
@@ -68,6 +69,17 @@ def test_usm_ndarray_flags():
6869
(5, 1, 2), dtype="i4", strides=(1, 0, 5)
6970
).flags.f_contiguous
7071
assert dpt.usm_ndarray((5, 1, 1), dtype="i4", strides=(1, 0, 1)).flags.fc
72+
x = dpt.empty(5, dtype="u2")
73+
assert x.flags.writable is True
74+
x.flags.writable = False
75+
assert x.flags.writable is False
76+
with pytest.raises(ValueError):
77+
x[:] = 0
78+
x.flags["W"] = True
79+
assert x.flags.writable is True
80+
x.flags["WRITABLE"] = True
81+
assert x.flags.writable is True
82+
x[:] = 0
7183

7284

7385
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)