Commit 9131925
authored
Improve raise TypeError by providing exception message (#1460)
Closes gh-1457
```
In [1]: import dpctl.tensor as dpt
In [2]: dpt.asnumpy([1,2,3])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 dpt.asnumpy([1,2,3])
File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:185, in asnumpy(usm_ary)
169 def asnumpy(usm_ary):
170 """
171 asnumpy(usm_ary)
172
(...)
183 of `usm_ary`
184 """
--> 185 return _copy_to_numpy(usm_ary)
File ~/repos/dpctl/dpctl/tensor/_copy_utils.py:40, in _copy_to_numpy(ary)
38 def _copy_to_numpy(ary):
39 if not isinstance(ary, dpt.usm_ndarray):
---> 40 raise TypeError(
41 f"Expected dpctl.tensor.usm_ndarray, got {type(ary)}"
42 )
43 nb = ary.usm_data.nbytes
44 hh = dpm.MemoryUSMHost(nb, queue=ary.sycl_queue)
TypeError: Expected dpctl.tensor.usm_ndarray, got <class 'list'>
In [3]: quit
```1 parent 02e7714 commit 9131925
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments