Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ```
- Loading branch information