diff --git a/bindings/rascal/utils/__init__.py b/bindings/rascal/utils/__init__.py index 8a9b63aeb..70cb05b88 100644 --- a/bindings/rascal/utils/__init__.py +++ b/bindings/rascal/utils/__init__.py @@ -7,27 +7,14 @@ dump_obj, load_obj, ) +from .misc import is_notebook + +# Warning potential dependency loop: FPS imports models, which imports KRR, +# which imports this file again from .fps import fps, FPSFilter + +# function to redirect c++'s standard output to python's one from ..lib._rascal.utils import ostream_redirect -from ..lib import utils from copy import deepcopy from .cur import CURFilter from .scorer import get_score, print_score - -# function to redirect c++'s standard output to python's one -ostream_redirect = utils.__dict__["ostream_redirect"] - - -def is_notebook(): - from IPython import get_ipython - - try: - shell = get_ipython().__class__.__name__ - if shell == "ZMQInteractiveShell": - return True # Jupyter notebook or qtconsole - elif shell == "TerminalInteractiveShell": - return False # Terminal running IPython - else: - return False # Other type (?) - except NameError: - return False # Probably standard Python interpreter diff --git a/bindings/rascal/utils/misc.py b/bindings/rascal/utils/misc.py new file mode 100644 index 000000000..8d77f6c79 --- /dev/null +++ b/bindings/rascal/utils/misc.py @@ -0,0 +1,17 @@ +"""Miscellaneous useful utilities""" + + +def is_notebook(): + """Is this being run inside an IPython Notebook?""" + from IPython import get_ipython + + try: + shell = get_ipython().__class__.__name__ + if shell == "ZMQInteractiveShell": + return True # Jupyter notebook or qtconsole + elif shell == "TerminalInteractiveShell": + return False # Terminal running IPython + else: + return False # Other type (?) + except NameError: + return False # Probably standard Python interpreter