8000 Update the specification for `remainder` to include special cases for floating-point operands by kgryte · Pull Request #401 · data-apis/array-api · GitHub
[go: up one dir, main page]

Skip to content

Update the specification for remainder to include special cases for floating-point operands #401

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 7 commits into from
Mar 21, 2022

Conversation

kgryte
Copy link
Contributor
@kgryte kgryte commented Mar 10, 2022

This PR

  • updates the specification for remainder (and, by extension, the __mod__ method) to include special cases for floating-point operands.
  • adds guidance intended to match Python's % operator.
  • adds a comment recommending against the use of remainder for floating-point operands, given that behavior does not follow IEEE 754 (i.e., results can deviate from r = x - n*floor(x/y), particularly during overflow and underflow). As floating-point operand acceptance is common across all implementing array libraries, the specification permits their support for reasons of backward compatibility.
  • resolves remainder() should have special cases #385.

@kgryte kgryte added the Maintenance Bug fix, typo fix, or general maintenance. label Mar 10, 2022
@kgryte kgryte requested a review from honno March 10, 2022 01:35
kgryte and others added 4 commits March 10, 2022 01:39
Co-authored-by: Matthew Barber <quitesimplymatt@gmail.com>
Co-authored-by: Matthew Barber <quitesimplymatt@gmail.com>
Co-authored-by: Matthew Barber <quitesimplymatt@gmail.com>
Co-authored-by: Matthew Barber <quitesimplymatt@gmail.com>
Copy link
Member
@honno honno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Also, ran these special cases through the test suite (specifically data-apis/array-api-tests#104)—they're all machine-readable, and pass for numpy.array_api.

@kgryte
Copy link
Contributor Author
kgryte commented Mar 10, 2022

Awesome! Thanks, @honno!

@kgryte
Copy link
Contributor Author
kgryte commented Mar 21, 2022

As this has been open for review for over 10 days and has been approved, will merge.

@kgryte kgryte merged commit c16f5fa into main Mar 21, 2022
@kgryte kgryte deleted the remainder-updates branch March 21, 2022 07:57
@kgryte kgryte added this to the v2021 milestone Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Bug fix, typo fix, or general maintenance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remainder() should have special cases
2 participants
0