Skip to content

Conversation

@oleksandr-pavlyk
Copy link
Contributor

Fixes #698

When processing sequence of sequences, pass requested array data type
to numpy converter to ensure that the expected ValueError is raised:

In [2]: import dpctl.tensor as dpt

In [3]: dpt.asarray([float("nan"), -1, 1], dtype="i8")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-5393cc22ddff> in <module>
----> 1 dpt.asarray([float("nan"), -1, 1], dtype="i8")

/.../dpctl/dpctl/tensor/_ctors.py in asarray(obj, dtype, device, copy, usm_type, sycl_queue, order)
    389         if devs == _host_set:
    390             return _asarray_from_numpy_ndarray(
--> 391                 np.asarray(obj, dtype=dtype, order=order),
    392                 dtype=dtype,
    393                 usm_type=usm_type,

~/..../site-packages/numpy/core/_asarray.py in asarray(a, dtype, order, like)
    100         return _asarray_with_like(a, dtype=dtype, order=order, like=like)
    101
--> 102     return array(a, dtype, copy=False, order=order)
    103
    104

ValueError: cannot convert float NaN to integer

In [4]: quit

When processing sequence of sequences, pass requested array data type
to numpy converter to ensure that the expected ValueError is raised
@github-actions
Copy link

github-actions bot commented Dec 4, 2021

@coveralls
Copy link
Collaborator

Coverage Status

Coverage remained the same at 81.194% when pulling 9c7426f on gh-698-asarray into 431bed8 on master.

@oleksandr-pavlyk oleksandr-pavlyk merged commit 9310e08 into master Dec 6, 2021
@oleksandr-pavlyk oleksandr-pavlyk deleted the gh-698-asarray branch December 6, 2021 12:45
@github-actions
Copy link

github-actions bot commented Dec 6, 2021

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dpctl.tensor.asarray([float("nan"), -1, 1], dtype="i8") doesn't raise ValueError like numpy

3 participants