Skip to content

Commit

Permalink
Adding functionality to detect running environment for simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Jun 14, 2021
1 parent ec164dd commit a45dfa7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tardis/util/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import tardis
from tardis.io.util import get_internal_data_path
from IPython import get_ipython

k_B_cgs = constants.k_B.cgs.value
c_cgs = constants.c.cgs.value
Expand Down Expand Up @@ -539,3 +540,25 @@ def convert_abundances_format(fname, delimiter=r"\s+"):
# Assign header row
df.columns = [nucname.name(i) for i in range(1, df.shape[1] + 1)]
return df


def check_simulation_env():
"""
Checks for the Simulation Environment
Returns
-------
True : if the environment is IPython Based
False : if the environment is Terminal or anything else
"""
try:
shell = get_ipython().__class__.__name__
except NameError:
return False

if shell == "ZMQInteractiveShell":
return True
elif shell == "TerminalInteractiveShell":
return False
else:
return False

0 comments on commit a45dfa7

Please sign in to comment.