Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dpctl/tensor/_usmarray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ cdef class usm_ndarray:
self.shape_ = shape_ptr
self.strides_ = strides_ptr
self.typenum_ = typenum
self.flags_ = contig_flag
self.flags_ = (contig_flag | USM_ARRAY_WRITABLE)
self.nd_ = nd
self.array_namespace_ = array_namespace

Expand Down Expand Up @@ -952,6 +952,8 @@ cdef class usm_ndarray:
_copy_from_numpy_into,
_copy_from_usm_ndarray_to_usm_ndarray,
)
if ((<usm_ndarray> Xv).flags_ & USM_ARRAY_WRITABLE) == 0:
raise ValueError("Can not modify read-only array.")
if isinstance(val, usm_ndarray):
_copy_from_usm_ndarray_to_usm_ndarray(Xv, val)
else:
Expand Down
6 changes: 4 additions & 2 deletions dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,13 @@ def test_full_dtype_inference():
assert np.issubdtype(dpt.full(10, 4).dtype, np.integer)
assert dpt.full(10, True).dtype is dpt.dtype(np.bool_)
assert np.issubdtype(dpt.full(10, 12.3).dtype, np.floating)
assert np.issubdtype(dpt.full(10, 0.3 - 2j).dtype, np.complexfloating)
cdt = dpt.full(10, 0.3 - 2j).dtype
assert np.issubdtype(cdt, np.complexfloating)

assert np.issubdtype(dpt.full(10, 12.3, dtype=int).dtype, np.integer)
assert np.issubdtype(dpt.full(10, 0.3 - 2j, dtype=int).dtype, np.integer)
assert np.issubdtype(dpt.full(10, 0.3 - 2j, dtype=float).dtype, np.floating)
rdt = np.finfo(cdt).dtype
assert np.issubdtype(dpt.full(10, 0.3 - 2j, dtype=rdt).dtype, np.floating)


def test_full_fill_array():
Expand Down