[Numpy-discussion] C99 compatible complex number tests fail
Matti Picus
matti.picus at gmail.com
Sun Dec 22 18:14:03 EST 2013
Hi. I started to port the stdlib cmath C99 compatible complex number
tests to numpy, after noticing that numpy seems to have different
complex number routines than cmath. The work is available on a
"retest_complex" branch of numpy
https://github.com/mattip/numpy/tree/retest_complex
The tests can be run by pulling the branch (no need to rebuild numpy)
and running
python <path-to-branch>/numpy/core/tests/test_umath_complex.py >
test.log 2>&1
So far it is just a couple of commits that run the tests on numpy, I
did not dive into modifying the math routines. If I did the work
correctly, failures point to some differences, most due to edge cases
with inf and nan, but there are a number of failures due to different
finite values (for some small definition of different).
I guess my first question is "did I do the tests properly".
Assuming I did, the next question is "are the inconsistencies
intentional" i.e. are they that way in order to be compatible with
Matlab or some other non-C99 conformant library?
For instance, a comparison between the implementation of cmath's sqrt
and numpy's sqrt shows that numpy does not check for subnormals. And I
am probably mistaken since I am new to the generator methods of numpy,
but could it be that trigonometric functions like acos and acosh are
generated in umath/funcs.inc.src, using a very different algorithm than
cmathmodule.c?
Would there be interest in a pull request that changed the routines to
be more compatible with results from cmath?
Matti
More information about the NumPy-Discussion
mailing list