summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2020-05-15 11:46:09 -0700
committerRoss Barnowski <rossbar@berkeley.edu>2020-05-15 12:20:42 -0700
commit4dc9ff62a78004d6debd0953d70cd39864b9d6c3 (patch)
tree509f01da7de17fa53e80b7c82055ce6634ad64d6
parent8922a6e025d53d5aaccba02b76dbef5a43afe768 (diff)
downloadnumpy-4dc9ff62a78004d6debd0953d70cd39864b9d6c3.tar.gz
DOC: Update poly class refguide printing.
Update routines.polynomials.classes doc in the refguide to reflect changes to polynomial printing. Add additional information to the document about the various ways that the string representation of polynomial expressions can be controlled via formatting.
-rw-r--r--doc/source/reference/routines.polynomials.classes.rst21
-rw-r--r--doc/source/reference/routines.polynomials.package.rst8
2 files changed, 26 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.
diff --git a/doc/source/reference/routines.polynomials.package.rst b/doc/source/reference/routines.polynomials.package.rst
index ca1217f80..1bc528c59 100644
--- a/doc/source/reference/routines.polynomials.package.rst
+++ b/doc/source/reference/routines.polynomials.package.rst
@@ -4,3 +4,11 @@
:no-members:
:no-inherited-members:
:no-special-members:
+
+Configuration
+-------------
+
+.. autosummary::
+ :toctree: generated/
+
+ numpy.polynomial.set_default_printstyle