qnet.printing.base module¶
Provides the base class for Printers
Reference¶
-
class
qnet.printing.base.QnetBasePrinter(cache=None, settings=None)[source]¶ Bases:
sympy.printing.printer.PrinterBase class for all QNET expression printers
Parameters: Class Attributes: - sympy_printer_cls (type) – The class that will be instantiated to print Sympy expressions
- _default_settings (dict) – The default value of all settings. Note only settings for which there are defaults defined here are accepted when instantiating the printer
- printmethod (None or str) – Name of a method that expressions may define to print themeselves.
Attributes: - cache (dict) – Dictionary where the results of any call to
doprint()is stored. Whendoprint()is called for an expression that is already in cache, the result from the cache is returned. - _sympy_printer (sympy.printing.printer.Printer) – The printer instance that will be used to print any Sympy expression.
- _allow_caching (bool) – A flag that may be set to completely disable caching
- _print_level (int) – The recursion depth of
doprint()(>= 1 inside any of the_print*methods)
Raises: TypeError– If any key in settings is not defined in the _default_settings of the printer, respectively the sympy_printer_cls.-
sympy_printer_cls¶ alias of
qnet.printing.sympy.SympyStrPrinter
-
printmethod= None¶
-
emptyPrinter(expr)[source]¶ Fallback method for expressions that neither know how to print themeselves, nor for which the printer has a suitable
_print*method
-
doprint(expr, *args, **kwargs)[source]¶ Returns printer’s representation for expr (as a string)
The representation is obtained by the following methods:
- from the
cache - If expr is a Sympy object, delegate to the
doprint()method of_sympy_printer - Let the expr print itself if has the
printmethod - Take the best fitting
_print_*method of the printer - As fallback, delegate to
emptyPrinter()
Any extra args or kwargs are passed to the internal _print method.
- from the