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Β²