Skip to content

Add floating-point special cases for floor_divide - #329

Merged
kgryte merged 4 commits into
mainfrom
floor-divide-special-cases
Nov 29, 2021
Merged

kgryte merged 4 commits into
mainfrom
floor-divide-special-cases

Conversation

@kgryte

@kgryte kgryte commented Nov 9, 2021 •

Copy link
Copy Markdown
Contributor

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
Comment thread spec/API_specification/array_object.md Outdated
@asmeurer

Copy link
Copy Markdown
Member

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

@kgryte

kgryte commented Nov 15, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and confirming @asmeurer!

@kgryte

kgryte commented Nov 29, 2021

Copy link
Copy Markdown
Contributor Author

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