Commit 81c8104f authored by Joseph Weston's avatar Joseph Weston
Browse files

make 'display_family' work even in the absence of IPython

Just fallback to regular printing.
parent e439fb80
Pipeline #23488 passed with stage
in 2 minutes and 45 seconds
......@@ -298,9 +298,11 @@ def hamiltonian_from_family(family, coeffs=None, nsimplify=True, tosympy=True):
def display_family(family, summed=False, coeffs=None, nsimplify=True):
"""Helper function to display a Hamiltonian family.
Supports LaTeX display through Sympy in a Jupyter notebook, which may be enabled
by running sympy.init_printing(print_builtin=True).
"""Display a Hamiltonian family in a Jupyter notebook
If this function is used from a Jupyter notebook then it uses the notebook's
rich LaTeX display features. If used from a console or script, then this
function just uses :func:`print`.
......@@ -316,6 +318,11 @@ def display_family(family, summed=False, coeffs=None, nsimplify=True):
floating point numbers with simpler expressions, e.g. fractions.
from IPython.display import display
except ImportError:
display = print
if not summed:
# print each member in the family separately
for term in family:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment