numpy.polynomial.set_default_printstyle#

polynomial.set_default_printstyle(style)[source]#

Set the default format for the string representation of polynomials.

Values for style must be valid inputs to __format__, i.e. β€˜ascii’ or β€˜unicode’.

Parameters:
stylestr

Format string for default printing style. Must be either β€˜ascii’ or β€˜unicode’.

Notes

The default format depends on the platform: β€˜unicode’ is used on Unix-based systems and β€˜ascii’ on Windows. This determination is based on default font support for the unicode superscript and subscript ranges.

Examples

>>> p = np.polynomial.Polynomial([1, 2, 3])
>>> c = np.polynomial.Chebyshev([1, 2, 3])
>>> np.polynomial.set_default_printstyle('unicode')
>>> print(p)
1.0 + 2.0Β·x + 3.0Β·xΒ²
>>> print(c)
1.0 + 2.0Β·T₁(x) + 3.0Β·Tβ‚‚(x)
>>> np.polynomial.set_default_printstyle('ascii')
>>> print(p)
1.0 + 2.0 x + 3.0 x**2
>>> print(c)
1.0 + 2.0 T_1(x) + 3.0 T_2(x)
>>> # Formatting supersedes all class/package-level defaults
>>> print(f"{p:unicode}")
1.0 + 2.0Β·x + 3.0Β·xΒ²