[pypy-dev] numpy fails trigonometry with complex numbers, what to do?

Armin Rigo arigo at tunes.org
Thu Sep 6 09:12:52 CEST 2012


Hi,

On Wed, Sep 5, 2012 at 3:30 AM, Matti Picus <matti.picus at gmail.com> wrote:
>>>> numpy.arccos(complex(0.,-0.))
> (1.5707963267948966-0j)
>>>> cmath.acos(complex(0.,-0.))
> (1.5707963267948966+0j)

>>>> cmath.acos(complex(float('inf'),2.3))
> -infj
>>>> numpy.arccos(complex(float('inf'),2.3))
> (0.78539816339744828-inf*j)

According to the C99 standard Annex G (draft,
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf), the cmath
answer is the correct one in both cases.  I don't know if that really
means that numpy didn't care about the details.  It sounds a bit
strange given that it has tests for it; I fear it rather means that
numpy implemented a different standard.  But maybe that's me being too
optimistic/pessimistic (depending on the point of view).  I would
indeed ask on numpy mailing lists or submit a bug entry and see their
reaction.


A bientôt,

Armin.


More information about the pypy-dev mailing list