From 09cbb7495b92a37ddfb5e7d1bc2e9964bc6a0609 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Sun, 13 Dec 2020 17:08:40 -0800 Subject: [PATCH] DOC: Fix a couple of reference to verbatim and vice versa This update a coupe of references (single backticks) that actually are not to verbatim/code (double backticks); and a couple of verbatim to reference when they do actually exists and can be resolved in context. I probably missed other; and stayed simple but spoted a few other inconsistencies that I did not fix: - some ``...`` could actually be :math:`...` but not always clear if it would be better. - some intervals are [``...``], other are ``[...]`` I guess they could be discussed individually; it was mostly the failing references that bothered me. --- numpy/core/code_generators/ufunc_docstrings.py | 12 ++++++------ numpy/lib/polynomial.py | 4 ++-- numpy/lib/scimath.py | 8 ++++---- numpy/polynomial/polynomial.py | 6 +++--- numpy/testing/_private/utils.py | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index b7edd2834b43..04181fbc2e92 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -185,7 +185,7 @@ def add_newdoc(place, name, doc): Notes ----- `arccos` is a multivalued function: for each `x` there are infinitely - many numbers `z` such that `cos(z) = x`. The convention is to return + many numbers `z` such that ``cos(z) = x``. The convention is to return the angle `z` whose real part lies in `[0, pi]`. For real-valued input data types, `arccos` always returns real output. @@ -193,7 +193,7 @@ def add_newdoc(place, name, doc): it yields ``nan`` and sets the `invalid` floating point error flag. For complex-valued input, `arccos` is a complex analytic function that - has branch cuts `[-inf, -1]` and `[1, inf]` and is continuous from + has branch cuts ``[-inf, -1]`` and `[1, inf]` and is continuous from above on the former and from below on the latter. The inverse `cos` is also known as `acos` or cos^-1. @@ -245,7 +245,7 @@ def add_newdoc(place, name, doc): ----- `arccosh` is a multivalued function: for each `x` there are infinitely many numbers `z` such that `cosh(z) = x`. The convention is to return the - `z` whose imaginary part lies in `[-pi, pi]` and the real part in + `z` whose imaginary part lies in ``[-pi, pi]`` and the real part in ``[0, inf]``. For real-valued input data types, `arccosh` always returns real output. @@ -406,7 +406,7 @@ def add_newdoc(place, name, doc): it yields ``nan`` and sets the `invalid` floating point error flag. For complex-valued input, `arctan` is a complex analytic function that - has [`1j, infj`] and [`-1j, -infj`] as branch cuts, and is continuous + has [``1j, infj``] and [``-1j, -infj``] as branch cuts, and is continuous from the left on the former and from the right on the latter. The inverse tangent is also known as `atan` or tan^{-1}. @@ -544,7 +544,7 @@ def add_newdoc(place, name, doc): Notes ----- `arctanh` is a multivalued function: for each `x` there are infinitely - many numbers `z` such that `tanh(z) = x`. The convention is to return + many numbers `z` such that ``tanh(z) = x``. The convention is to return the `z` whose imaginary part lies in `[-pi/2, pi/2]`. For real-valued input data types, `arctanh` always returns real output. @@ -765,7 +765,7 @@ def add_newdoc(place, name, doc): Return the ceiling of the input, element-wise. The ceil of the scalar `x` is the smallest integer `i`, such that - `i >= x`. It is often denoted as :math:`\\lceil x \\rceil`. + ``i >= x``. It is often denoted as :math:`\\lceil x \\rceil`. Parameters ---------- diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 0fd9bbd79c6a..ea966ffa343b 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -708,8 +708,8 @@ def polyval(p, x): ``p[0]*x**(N-1) + p[1]*x**(N-2) + ... + p[N-2]*x + p[N-1]`` - If `x` is a sequence, then `p(x)` is returned for each element of `x`. - If `x` is another polynomial then the composite polynomial `p(x(t))` + If `x` is a sequence, then ``p(x)`` is returned for each element of ``x``. + If `x` is another polynomial then the composite polynomial ``p(x(t))`` is returned. Parameters diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py index 2b0d38c37f2b..ed9ffd295b90 100644 --- a/numpy/lib/scimath.py +++ b/numpy/lib/scimath.py @@ -572,10 +572,10 @@ def arctanh(x): Compute the inverse hyperbolic tangent of `x`. Return the "principal value" (for a description of this, see - `numpy.arctanh`) of `arctanh(x)`. For real `x` such that - `abs(x) < 1`, this is a real number. If `abs(x) > 1`, or if `x` is + `numpy.arctanh`) of ``arctanh(x)``. For real `x` such that + ``abs(x) < 1``, this is a real number. If `abs(x) > 1`, or if `x` is complex, the result is complex. Finally, `x = 1` returns``inf`` and - `x=-1` returns ``-inf``. + ``x=-1`` returns ``-inf``. Parameters ---------- @@ -597,7 +597,7 @@ def arctanh(x): ----- For an arctanh() that returns ``NAN`` when real `x` is not in the interval ``(-1,1)``, use `numpy.arctanh` (this latter, however, does - return +/-inf for `x = +/-1`). + return +/-inf for ``x = +/-1``). Examples -------- diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index 1baa7d870881..44784023bfd9 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -156,7 +156,7 @@ def polyfromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - where the `r_n` are the roots specified in `roots`. If a zero has + where the ``r_n`` are the roots specified in `roots`. If a zero has multiplicity n, then it must appear in `roots` n times. For instance, if 2 is a root of multiplicity three and 3 is a root of multiplicity 2, then `roots` looks something like [2, 2, 2, 3, 3]. The roots can appear @@ -192,11 +192,11 @@ def polyfromroots(roots): Notes ----- The coefficients are determined by multiplying together linear factors - of the form `(x - r_i)`, i.e. + of the form ``(x - r_i)``, i.e. .. math:: p(x) = (x - r_0) (x - r_1) ... (x - r_n) - where ``n == len(roots) - 1``; note that this implies that `1` is always + where ``n == len(roots) - 1``; note that this implies that ``1`` is always returned for :math:`a_n`. Examples diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index e974bbd0911a..b4d42728e3cd 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -481,7 +481,7 @@ def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): instead of this function for more consistent floating point comparisons. - The test verifies that the elements of ``actual`` and ``desired`` satisfy. + The test verifies that the elements of `actual` and `desired` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)``