Skip to content

Commit b5265a8

Browse files
Test to check that RO flags is preserved by asarray
1 parent 97061ee commit b5265a8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,3 +2368,28 @@ def test_gh_1201():
23682368
c = dpt.flip(dpt.empty(a.shape, dtype=a.dtype))
23692369
c[:] = a
23702370
assert (dpt.asnumpy(c) == a).all()
2371+
2372+
2373+
class ObjWithSyclUsmArrayInterface:
2374+
def __init__(self, ary):
2375+
self._array_obj = ary
2376+
2377+
@property
2378+
def __sycl_usm_array_interface__(self):
2379+
_suai = self._array_obj.__sycl_usm_array_interface__
2380+
return _suai
2381+
2382+
2383+
def test_asarray_writable_flag():
2384+
try:
2385+
a = dpt.empty(8)
2386+
except dpctl.SyclDeviceCreationError:
2387+
pytest.skip("No SYCL devices available")
2388+
2389+
a.flags["W"] = False
2390+
wrapped = ObjWithSyclUsmArrayInterface(a)
2391+
2392+
b = dpt.asarray(wrapped)
2393+
2394+
assert not b.flags["W"]
2395+
assert b._pointer == a._pointer

0 commit comments

Comments
 (0)