Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

dpt.diff does not raise a validation exception for n < 0 #1779

Copy link
Copy link
@antonwolfy

Description

@antonwolfy
Issue body actions

Below example shows that numpy raises exception for negative n passed to numpy.diff:

import numpy, dpctl, dpctl.tensor as dpt

a = numpy.array([0, 1, 2])
numpy.diff(a, n=-1)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[11], line 1
----> 1 numpy.diff(a, n=-1)

File ~/miniforge3/envs/dpnp_dev/lib/python3.11/site-packages/numpy/lib/function_base.py:1412, in diff(a, n, axis, prepend, append)
   1410     return a
   1411 if n < 0:
-> 1412     raise ValueError(
   1413         "order must be non-negative but got " + repr(n))
   1415 a = asanyarray(a)
   1416 nd = a.ndim

ValueError: order must be non-negative but got -1

# no exception raised by dpctl:
a = dpt.asarray(a)
dpt.diff(a, n=-1)
# Out: usm_ndarray([1, 1])

but no exception raised by dpctl. Is it intended or validation was missed?

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.