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
Fix round #494
Fix round #494
Conversation
And tests passed in dipy-py2.7-win32 too =D |
#endif | ||
|
||
/* From numpy npy_math.c.src */ | ||
#ifndef HAVE_RINT |
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 looks good, out of curiosity when do we expect npy_math to not have npy_rint
?
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.
Honestly, I don't know, I may have been too "paranoid", like the codility.com guys say: "Assume nothing, trust no one" ;-) . Maybe it's not necessary, I'll check as soon as the buildbots get back online =)
I was reading a bit more the numpy code and I think the npy_* versions are always available. If the native version is available, they simply decorate them with prefix 'npy_': https://github.com/numpy/numpy/blob/a435de365a603f29bf243882644f1e26edda6e9a/numpy/core/src/npymath/npy_math.c.src#L433 and if the native function is not available, then they define different versions of their own implementation with different types of arguments and return values: here is where they call the (generic) version for each return/parameter type: so, in theory, it should be possible to simply call the npy_* version without adding any extra code in dpy_math.h (just including "numpy/npy_math.h" should be enough). Unfortunately the win32 buildbots are still offline... I'll try this as soon as they are back online. |
Not sure what is happening with the buildbots, but I suspect there was a There's a 'storm' at the moment in Berkeley apparently. Thomas Kluyver |
3571a29
to
771b611
Compare
Hi!, I hope you guys are fine after the big storm!. The buildbots are working now, and we effectively can just include "numpy/npy_math.h" from "dpy_math.h" and use all the "npy_*" functions without adding any extra code. After that, the tests pass in win32: |
Nice! Thx! |
This is a follow-up to #493.
Apparently, round is not defined in c++98:
http://stackoverflow.com/questions/485525/round-for-float-in-c
which causes this error:
http://nipy.bic.berkeley.edu/builders/dipy-py2.7-win32/builds/124/steps/shell_5/logs/stdio
Using floor(x+0.5) may not be consistent with numpy, we also need to consider rounding to nearest even:
http://mathematica.stackexchange.com/questions/2116/why-round-to-even-integers
This solution uses the same procedure as for "dpy_log2", by borrowing code from numpy:
https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/npy_math.c.src
The code now builds in buildbot dipy-py2.7-win32:
http://nipy.bic.berkeley.edu/builders/dipy-py2.7-win32/builds/127/steps/shell_5/logs/stdio