-
Notifications
You must be signed in to change notification settings - Fork 52
Add signbit
specification for determining whether a sign bit is set
#705
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, thanks @kgryte. One sentence I'd add to the returns section is that for negative values the result is expected to be True
, and for positive values False
. That won't be completely obvious otherwise to readers not familiar with the low-level details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume input shape-preserving is an implicit assumption, given that signbit
just follows other elementwise docs?
@rgommers Isn't that already covered in the special cases section?
|
@leofang That is correct. We don't explicitly mention the expected output shape across the element-wise specifications, but we should probably be explicit. I can submit a follow-up PR to address this more broadly. |
No, special cases are special for a reason, and should not be needed to deduce the main behavior of a function. The text always has to make sense if you'd simply delete the special cases section. |
IMO this is splitting hairs. The main behavior is precisely as described, as the API should not be confused with the signum function. Meaning, using
|
It is not a big ask to add something like: "if the sign bit of a value is set, i.e. has value 1 or the value has a minus sign, the result will be False". Or add the math expression like the |
@rgommers I've added an extended description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kgryte, LGTM now.
Two approvals and everyone was happy with this addition, so I'll hit the green button here. |
This PR
signbit
for determining whether a sign bit is set for each floating-point number in a provided input array.+0
and-0
and the determining the sign ofNaN
, values which are not possible outside of floating-point data types. For complex data types, users need to provide the real and imaginary components separately.