-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
After #9365 was merged, @taldcroft noticed that "In a clean build of master right now I'm seeing this:"
In [1]: from astropy.io import ascii
WARNING: leap-second auto-update failed due to the following exception: ImportError("cannot import name 'convert_numpy'",) [astropy.time.core]
???
Clearly, import order is important in ways it shouldn't be. I'll investigate but suggestions would be most welcome...
EDIT: reason it is tricky: many of the most common time formats need an up-to-date leap-second table (e.g., Time.now() uses TimeDatetime, which, like TimeISO* calls erfa.dtf2d, which needs leap second information. But the LeapSecond class subclasses QTable, so needs to import astropy.table. Table itself only imports Time locally, so is safe, but some parts of io.ascii import Time on top and therefore are not.
Possible solutions:
- Make
LeapSecondsa class independent ofTable- which means also moving it out ofiers. That means parsing the files outside ofio.asciiand having very IERS-like configuration elsewhere; this seems a horrible duplication of work. - Ensure
Timeis imported only locally inio. But it seems rather annoying not to be able to count on being able to import such a fundamental class. - Ensure
erfais imported only locally inTime,iers, etc., and move the update back there. More than a little annoying, since used a lot intime.formats. Also, is a very basic package that should just be importable (and is not currently causing the problems). - Ensure the leap-second update is only done on first use of
Time.
Option (4) may be the best. Should I do this with something in Time.__new__?
cc @taldcroft, @eteq