-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
MAINT: Separate correct longdouble.__float__
from incorrect longdouble.__int__
#9967
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
|
||
dval = (double)(((Py@CHAR@LongDoubleScalarObject *)self)->obval)@POST@; |
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.
Using PyArrayScalar_VAL
in favor of this
* #POST = ,,.real*2# | ||
* #char = ,c# | ||
* #CHAR = ,C# | ||
* #POST = ,.real# | ||
*/ |
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.
This repeat is way clearer expressed as two repeats
* Could fix this with a PyLong_FromLongDouble(longdouble ldval) | ||
* but this would need some more work... | ||
*/ | ||
return PyLong_FromDouble((double) val); |
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.
This is where things need to change to fix #9964, but lets leave that to a future PR.
*/ | ||
@char@longdoubletype_as_number.nb_float = @char@longdoubletype_float; | ||
#if defined(NPY_PY3K) | ||
@char@longdoubletype_as_number.nb_int = @char@longdoubletype_long; |
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.
This is deliberate, as nb_int should try to return int
on py2, but long
on py3. I'm not sure it makes a difference externaly (I suspect python deals with either return value), but it's more consistent with how longobject
is implemented.
PyCLongDoubleArrType_Type.@kind@_@name@ = clongdoubletype_@name@; | ||
Py@CHAR@LongDoubleArrType_Type.tp_as_number = &@char@longdoubletype_as_number; | ||
Py@CHAR@LongDoubleArrType_Type.tp_repr = @char@longdoubletype_repr; | ||
Py@CHAR@LongDoubleArrType_Type.tp_str = @char@longdoubletype_str; |
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.
It's far more readable and concise to iterate over the types here, rather than the members.
…uble.__int__` These barely shared any useful code at all.
49c624a
to
7b4ec2a
Compare
Thanks Eric. |
These barely shared any useful code at all, and it makes it clearer where the fix needs to go for #9964