for some reason from libc.math cimport M_PI imports M_PI as type int
and of value 3. I think it might have to do with declaring M_PI as
enum (not sure what that does). Can anyone reproduce this?
-Thomas
for now my workaround is:
cdef extern from "math.h":
double M_PI
Which works fine. But this seems to be a bug.
-Thomas
Definitely a bug, fixed at
https://github.com/cython/cython/commit/8a74aefcde864c76dffd2eeeb497395ae7aea172
Declaring M_PI as an enum makes it more "constant-like" but also
caused it to treat it as an integer for purposes of
conversion/inference. Thanks for the report.
- Robert
Thanks for the report and very quick fix. In my calculations M_PI is
used at least more than 5 times. Knowing that M_PI was misbehaving is
important to me. With this example I see the importance of writing
test cases, hopefully soon I will adopt this habit for my code.
--
Gökhan
Note that it only happened if it was immediately used in an
object/integer context, but still a very bad bug.
> With this example I see the importance of writing
> test cases, hopefully soon I will adopt this habit for my code.
Yep. We even had a test of math.pxd here, just not a good enough one :).
- Robert