Skip to content

feat: add diff to specification #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2024
Merged

feat: add diff to specification #791

merged 2 commits into from
Sep 19, 2024

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Apr 18, 2024

This PR

  • resolves RFC: add diff for computing the n-th forward difference #784 by adding diff to the specification.
  • restricts portable behavior for prepend and append to arrays. While NumPy and others support scalars (a common use case), PyTorch does not support scalars.
  • supports all numeric dtypes (real and complex floats, signed and unsigned integers).
  • allows some wiggle room for array libraries supporting "exotic" dtypes, such as datetimes, by stating that the output array "should" have the same data type as the input array x. E.g., NumPy supports datetimes and returns timedeltas. For numeric dtypes, the output array should always have the same dtype.
  • restricts prepend and append to the same data type as the input array. If we more generally allow any combination of dtypes among x, prepend, and append, we'd need to consider type promotion semantics. We don't have much, if any, precedent in the specification for array kwargs causing an input array to upcast, and I don't think we should establish precedent here.
  • set the defaults for prepend and append to None. This is in contrast to NumPy which doesn't set a default value.

@kgryte kgryte added the API extension Adds new functions or objects to the API. label Apr 18, 2024
@kgryte kgryte added the Needs Review Pull request which needs review. label Apr 18, 2024
@kgryte kgryte added this to the v2024 milestone Apr 18, 2024
@kgryte kgryte removed the Needs Review Pull request which needs review. label Sep 19, 2024
@kgryte
Copy link
Contributor Author

kgryte commented Sep 19, 2024

As this PR has previously been discussed during workgroup meetings, does not have any open questions, and has not received any objections, I'll go ahead and merge.

@kgryte kgryte merged commit 45b705d into data-apis:main Sep 19, 2024
3 checks passed
@kgryte kgryte deleted the feat/diff branch September 19, 2024 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: add diff for computing the n-th forward difference
1 participant