-
-
Notifications
You must be signed in to change notification settings - Fork 12k
MAINT: avoid passing ints to functions that take double #30580
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
|
I'm a bit confused, as the documentation states that the fused type with greatest precision is used. Which of double and int64 is the type with greatest precision? We want double, but the warning says int64. |
What documentation are you referring to? Fused types allow you to write code that can be called with any one of an enumerated set of types. Precision doesn't come into place in my use here. In this PR, call sites that pass in ints will use the int version and call sites that use doubles will call the double version. There are two different functions for each case in the generated C code. Maybe the docs you're reading are talking about a fused type like |
|
My impression was that what is wanted is a cast of int64 to double, with maybe a check that the value is preserved. |
|
I’m implementing @rkern’s suggestion from here.
This is exactly that suggestion. I could have simply casted to double, but that could overflow and IMO this is better. |
rkern
left a comment
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! Thank you!
|
LGTM also, thanks all! |
…#30580) This avoids type unsafe function calls in cython random.
MAINT: avoid passing ints to random functions that take double (#30580)
Fixes #30578
See https://cython.readthedocs.io/en/latest/src/userguide/fusedtypes.html#type-checking-specializations if you're unfamiliar with the fused types specialization syntax I'm using.