Skip to content

Commit

Permalink
Add astropy import guard
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHls authored Nov 10, 2023
1 parent 87e8f3a commit 5da9cee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tardis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@
# ----------------------------------------------------------------------------

import sys
import warnings

# ----------------------------------------------------------------------------

from astropy import physical_constants, astronomical_constants
if ("astropy.units" in sys.modules) or ("astropy.constants" in sys.modules):
warnings.warn(
"Astropy is already imported externally. Astropy should be imported"
" after TARDIS."
)
else:
from astropy import physical_constants, astronomical_constants

physical_constants.set("codata2014")
astronomical_constants.set("iau2012")
physical_constants.set("codata2014")
astronomical_constants.set("iau2012")

# ----------------------------------------------------------------------------

Expand Down

0 comments on commit 5da9cee

Please sign in to comment.