Skip to content

Improved error handling for usm_ndarray.__setitem__ - #1146

Merged
oleksandr-pavlyk merged 1 commit into
masterfrom
improve-assignment-error-handling
Mar 30, 2023
Merged

oleksandr-pavlyk merged 1 commit into
masterfrom
improve-assignment-error-handling

Conversation

@oleksandr-pavlyk

Copy link
Copy Markdown
Contributor

While reviewing #1139 the following suboptimal behavior was highlighted:

import dpctl.tensor as dpt, numpy as np

u, n = dpt.empty(5), np.ones(5, dtype="O")
u[...] = n

This example used to raise a cascade of exceptions starting with cryptic "RuntimeError: Unrecogized typenum 17 encountered.", where typenum 17 corresponds to type object. The latest exception raised was ValueError.

After this change, the error message is crisper:

ValueError: Input of type <class 'numpy.ndarray'> can not be \
    assigned to usm_ndarray because of unsupported data \
    type 'object'

Tests exist.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you opening the PR as a draft?

```python
import dpctl.tensor as dpt, numpy as np

u, n = dpt.empty(5), np.ones(5, dtype="O")
u[...] = n
```

This example used to raise a cascade of exceptions starting
with cryptic  "RuntimeError: Unrecogized typenum 17 encountered.",
where typenum 17 corresponds to type object.

After this change, the error message is crisper:

```
ValueError: Input of type <class 'numpy.ndarray'> can not be \
    assigned to usm_ndarray because of unsupported data \
    type 'object'
```
@github-actions

Copy link
Copy Markdown

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage: 82.799% (-0.003%) from 82.802% when pulling 5929d6b on improve-assignment-error-handling into df25aa0 on master.

@github-actions

Copy link
Copy Markdown

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_38 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

@oleksandr-pavlyk
oleksandr-pavlyk merged commit 9ca3b6b into master Mar 30, 2023
@oleksandr-pavlyk
oleksandr-pavlyk deleted the improve-assignment-error-handling branch March 30, 2023 00:29
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_56 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

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.

3 participants