Skip to content

Commit 9ca3b6b

Browse files
Merge pull request #1146 from IntelPython/improve-assignment-error-handling
2 parents eec1594 + 5929d6b commit 9ca3b6b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

dpctl/tensor/_usmarray.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,13 +1110,19 @@ cdef class usm_ndarray:
11101110
"converted to usm_ndarray"
11111111
)
11121112
else:
1113+
rhs_np = np.asarray(rhs)
1114+
if type_bytesize(rhs_np.dtype.num) < 0:
1115+
raise ValueError(
1116+
f"Input of type {type(rhs)} can not be "
1117+
"assigned to usm_ndarray because of "
1118+
f"unsupported data type '{rhs_np.dtype}'"
1119+
)
11131120
try:
1114-
rhs_np = np.asarray(rhs)
11151121
_copy_from_numpy_into(Xv, rhs_np)
11161122
except Exception:
11171123
raise ValueError(
11181124
f"Input of type {type(rhs)} could not be "
1119-
"converted to usm_ndarray"
1125+
"copied into dpctl.tensor.usm_ndarray"
11201126
)
11211127
return
11221128

0 commit comments

Comments
 (0)