liberfa / pyerfa

Python bindings for ERFA routines
https://pyerfa.readthedocs.io
BSD 3-Clause "New" or "Revised" License
34 stars 24 forks source link

README example fails, and other issues are present in astropy when compiling project with -O3 #112

Open doronbehar opened 1 year ago

doronbehar commented 1 year ago

I'm trying to update this package at NixOS (2.0.0.1 -> 2.0.0.3), and I want to enable testing during build. Here's a full log of the failures I experience:

https://gist.github.com/doronbehar/a321da0ce4d254ff5de34d0e9c3af609

I will also mention that I had from some reason to remove the erfa directory before beginning the tests, as I encountered issues as explained in #92.

mhvk commented 1 year ago

Removing the erfa directory is in principle weird, since that contains the actual code, and I think that explains why in your test log only README.rst is tested. Have you tried to run the example that fails in a separate session? It works for me:

In [1]: import erfa

In [2]: erfa.jd2cal(2460000., [0, 1, 2, 3])
Out[2]: 
(array([2023, 2023, 2023, 2023], dtype=int32),
 array([2, 2, 2, 2], dtype=int32),
 array([24, 25, 26, 27], dtype=int32),
 array([0.5, 0.5, 0.5, 0.5]))
doronbehar commented 1 year ago

@mhvk I'm experiencing the same ValueError when I run what you said manually:

  File "/nix/store/29qpy4ln613m35gazmscg2drm8cxd4xz-python3.10-pyerfa-2.0.0.3/lib/python3.10/site-packages/erfa/core.py", line 592, in jd2cal
    iy, im, id, fd, c_retval = ufunc.jd2cal(dj1, dj2)
ValueError: Invalid data-type for array

I also tried to apply https://github.com/liberfa/pyerfa/commit/4866342b94c5e7344711146f1186a4c3e7534da8, but it did not help.

doronbehar commented 1 year ago

Oh now I see that with -O2, that code runs :) I guess https://github.com/liberfa/pyerfa/commit/4866342b94c5e7344711146f1186a4c3e7534da8 didn't do all the job :).

doronbehar commented 1 year ago

Unfortunately, now when I try to completely enable again the tests, I get the circular import errors as before... It is very peculiar, but not necessarily your responsibility. We investigate this apparently somewhat common issue in our repository at https://github.com/NixOS/nixpkgs/issues/255262 .

doronbehar commented 1 year ago

For reference, here's the full log with the circular import failures https://gist.github.com/doronbehar/9eefd3fdb24031e3879621114a6da76b .

mhvk commented 1 year ago

Interesting! I noticed that there indeed was a compiler warning in your log, which may be related (and which maybe we could fix). Could you do me a favour and raise a new issue just noticing that the actual example from README.rst fails if compiled with -O3? I don't think I'll have time today to look at it, but want to be sure we don't forget!

doronbehar commented 1 year ago

Could you do me a favour and raise a new issue just noticing that the actual example from README.rst fails if compiled with -O3?

This is sort of covered in the title of this issue no? "Doctests fail with -O3"

mhvk commented 1 year ago

That title tells the doctests fail - it asks the reader to find out what the doctests actually are (I at least wrote them, but I really didn't remember). Specific issues are super important to help maintenance!