Skip to content

Add floating-point special cases for floor_divide #329

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 4 commits into from
Nov 29, 2021

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Nov 9, 2021

This PR

  • adds guidance for special cases involving floating-point operands in floor_divide. The lack of guidance was initially raised in gh-199 (see comment). Upon investigation, NumPy's floor_divide is both inconsistent with floor(divide(x,y)) behavior and built-in Python behavior and also diverges from behavior found in other libraries (e.g., TensorFlow). Accordingly, this PR seeks to clarify behavior for floating-point operands and ensure consistency with floor(divide(x,y)) to avoid downstream user surprises. The documented special cases largely follow those of divide.
  • allows for array libraries to deviate in certain special cases involving infinities in order to match Python behavior.

@kgryte kgryte added this to the v2021 milestone Nov 9, 2021
@kgryte kgryte requested a review from asmeurer November 9, 2021 23:34
@asmeurer
Copy link
Member

These imported into the test suite just fine. I ran the tests and it found that NumPy deviates on those I mentioned.

@kgryte
Copy link
Contributor Author

kgryte commented Nov 15, 2021

Thanks for reviewing and confirming @asmeurer!

@kgryte
Copy link
Contributor Author

kgryte commented Nov 29, 2021

The changes introduced in this PR have been reviewed and were discussed at the consortium meeting on 18 November 2021. Will merge, and any subsequent edits can be made in follow-up PRs.

@asmeurer @honno You'll want to note that array libraries are allowed to deviate from behavior included in the spec for a subset of the special cases. These special cases are demarcated accordingly.

@kgryte kgryte merged commit 3e47648 into main Nov 29, 2021
@kgryte kgryte deleted the floor-divide-special-cases branch November 29, 2021 09:56
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.

4 participants