def iprint_latex(variable_name: str, variable_value=None, short: bool=False): """Display variables in IPython notebooks using LaTeX markup. Uses `math_object_to_latex`. This function sorts the input ``mobj`` if it is a :class:`~.Set` or a :class:`~.Multiset` to make the output consistent, so be careful with big (multi)sets. (Such large (multi)sets where this is a problem may not be suitable to display in LaTeX anyway.) :param variable_name: The name of the variable to display. :param variable_value: (Optional) The value of the variable. If it is missing, the variable value is fetched from the caller's frame; a variable with the name ``variable_name`` is assumed to exist in this case. :param short: (Optional) When set to ``True``, a short version of the content is generated. Longer parts are abbreviated with ellipses ('...'). Defaults to ``False``. See also `Config.short_atom_len` and `Config.short_set_len`. .. note:: This function imports from ``IPython`` and expects IPython to be installed. This is generally given when running in an IPython notebook. """ from IPython.display import Math, display if variable_value is None: variable_value = _misc.get_variable(variable_name, frames_up=1) variable_latex = math_object_to_latex(variable_value, short=short) variable_name_latex = variable_name.replace('_', r'\_') latex = '{name} = {value}'.format(name=variable_name_latex, value=variable_latex) display(Math(latex))
def iprint_latex(variable_name: str, variable_value=None, short: bool = False): """Display variables in IPython notebooks using LaTeX markup. Uses `math_object_to_latex`. This function sorts the input ``mobj`` if it is a :class:`~.Set` or a :class:`~.Multiset` to make the output consistent, so be careful with big (multi)sets. (Such large (multi)sets where this is a problem may not be suitable to display in LaTeX anyway.) :param variable_name: The name of the variable to display. :param variable_value: (Optional) The value of the variable. If it is missing, the variable value is fetched from the caller's frame; a variable with the name ``variable_name`` is assumed to exist in this case. :param short: (Optional) When set to ``True``, a short version of the content is generated. Longer parts are abbreviated with ellipses ('...'). Defaults to ``False``. See also `Config.short_atom_len` and `Config.short_set_len`. .. note:: This function imports from ``IPython`` and expects IPython to be installed. This is generally given when running in an IPython notebook. """ from IPython.display import Math, display if variable_value is None: variable_value = _misc.get_variable(variable_name, frames_up=1) variable_latex = math_object_to_latex(variable_value, short=short) variable_name_latex = variable_name.replace('_', r'\_') latex = '{name} = {value}'.format(name=variable_name_latex, value=variable_latex) display(Math(latex))
def iprint_latex(variable_name: str, variable_value=None, short: bool=False): """A utility to display variables in IPython notebooks. :param variable_name: The name of the variable to display. :param variable_value: The optional value of the variable. If it is missing, the variable value is fetched from the caller's frame; a variable with the name ``variable_name`` is assumed to exist in this case. :param short: When set to ``True``, a short version of the content is generated. Longer parts are abbreviated with ellipses ('...'). Defaults to ``False``. """ from IPython.display import Math, display if variable_value is None: variable_value = _misc.get_variable(variable_name, frames_up=1) variable_latex = math_object_to_latex(variable_value, short=short) variable_name_latex = variable_name.replace('_', r'\_') latex = '{name} = {value}'.format(name=variable_name_latex, value=variable_latex) display(Math(latex))