Interactive

Helper module for setting up interactive Diofant sessions.

AST transformations, provided here, could be used in IPython to reduce boilerplate while interacting with Diofant due to the Python language syntax.

diofant.interactive.printing.init_printing(no_global=False, pretty_print=None, **settings)[source]

Initializes pretty-printer depending on the environment.

Parameters:

no_global : boolean

If True, the settings become system wide; if False, use just for this console/session.

pretty_print : boolean or None

Enable pretty printer (turned on by default for IPython, but disabled for plain Python console).

**settings : dict

A dictionary of default settings for printers.

Notes

This function runs automatically for wildcard imports (e.g. for from diofant import *) in interactive sessions.

Examples

>>> from diofant.abc import theta
>>> sqrt(5)
sqrt(5)
>>> init_printing(pretty_print=True, no_global=True)
>>> sqrt(5)
  ___
╲╱ 5
>>> theta
θ
>>> init_printing(pretty_print=True, use_unicode=False, no_global=True)
>>> theta
theta
>>> init_printing(pretty_print=True, order='grevlex', no_global=True)
>>> y + x + y**2 + x**2
 2    2
x  + y  + x + y
class diofant.interactive.session.AutomaticSymbols[source]

Add missing Symbol definitions automatically.

class diofant.interactive.session.FloatRationalizer[source]

Wraps all floats in a call to Rational.

class diofant.interactive.session.IntegerDivisionWrapper[source]

Wrap all int divisions in a call to Rational.