summaryrefslogtreecommitdiff
path: root/doc/source/reference/routines.polynomials.classes.rst
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-06-04 08:38:30 +0300
committerGitHub <noreply@github.com>2020-06-04 08:38:30 +0300
commit821a18e55916d0d40227c58ea75f589ea3d9f078 (patch)
treebfc71a190b2488d5a71d07740b8aeb3f07e18bc2 /doc/source/reference/routines.polynomials.classes.rst
parent924cbe4dadcabd337a6d8b0ef6efa3091a3ed5fc (diff)
parent4dc9ff62a78004d6debd0953d70cd39864b9d6c3 (diff)
downloadnumpy-821a18e55916d0d40227c58ea75f589ea3d9f078.tar.gz
Merge pull request #15666 from rossbar/enh/poly_str
ENH: Improved `__str__` for polynomials
Diffstat (limited to 'doc/source/reference/routines.polynomials.classes.rst')
-rw-r--r--doc/source/reference/routines.polynomials.classes.rst21
1 files changed, 18 insertions, 3 deletions
diff --git a/doc/source/reference/routines.polynomials.classes.rst b/doc/source/reference/routines.polynomials.classes.rst
index 71e635866..10331e9c1 100644
--- a/doc/source/reference/routines.polynomials.classes.rst
+++ b/doc/source/reference/routines.polynomials.classes.rst
@@ -65,11 +65,26 @@ window::
>>> p.window
array([-1., 1.])
-Printing a polynomial yields a shorter form without the domain
-and window::
+Printing a polynomial yields the polynomial expression in a more familiar
+format::
>>> print(p)
- poly([1. 2. 3.])
+ 1.0 + 2.0·x¹ + 3.0·x²
+
+Note that the string representation of polynomials uses Unicode characters
+by default (except on Windows) to express powers and subscripts. An ASCII-based
+representation is also available (default on Windows). The polynomial string
+format can be toggled at the package-level with the
+`~numpy.polynomial.set_default_printstyle` function::
+
+ >>> numpy.polynomial.set_default_printstyle('ascii')
+ >>> print(p)
+ 1.0 + 2.0 x**1 + 3.0 x**2
+
+or controlled for individual polynomial instances with string formatting::
+
+ >>> print(f"{p:unicode}")
+ 1.0 + 2.0·x¹ + 3.0·x²
We will deal with the domain and window when we get to fitting, for the moment
we ignore them and run through the basic algebraic and arithmetic operations.