From d035e7c1fe4508e9a90d8f87cfbf53d41adf235c Mon Sep 17 00:00:00 2001 From: Yuki Date: Mon, 14 Aug 2023 09:52:03 +0000 Subject: [PATCH] DOC: Add missing sphinx reference roles --- doc/source/reference/c-api/array.rst | 2 +- numpy/core/_ufunc_config.py | 4 +- numpy/core/defchararray.py | 92 ++++++++++++++-------------- numpy/core/numeric.py | 8 +-- numpy/fft/__init__.py | 4 +- numpy/lib/stride_tricks.py | 4 +- numpy/lib/utils.py | 6 +- numpy/polynomial/chebyshev.py | 2 +- numpy/polynomial/hermite.py | 2 +- numpy/polynomial/hermite_e.py | 2 +- numpy/polynomial/laguerre.py | 2 +- numpy/polynomial/legendre.py | 2 +- numpy/polynomial/polynomial.py | 2 +- 13 files changed, 66 insertions(+), 66 deletions(-) diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst index bb92e149c328..c83571db1b7d 100644 --- a/doc/source/reference/c-api/array.rst +++ b/doc/source/reference/c-api/array.rst @@ -1080,7 +1080,7 @@ Converting data types Convert a sequence of Python objects contained in *op* to an array of ndarrays each having the same data type. The type is selected - in the same way as `PyArray_ResultType`. The length of the sequence is + in the same way as :c:func:`PyArray_ResultType`. The length of the sequence is returned in *n*, and an *n* -length array of :c:type:`PyArrayObject` pointers is the return value (or ``NULL`` if an error occurs). The returned array must be freed by the caller of this routine diff --git a/numpy/core/_ufunc_config.py b/numpy/core/_ufunc_config.py index f931d8d2cc6a..8cf56d5868d7 100644 --- a/numpy/core/_ufunc_config.py +++ b/numpy/core/_ufunc_config.py @@ -32,8 +32,8 @@ def seterr(all=None, divide=None, over=None, under=None, invalid=None): Set treatment for all types of floating-point errors at once: - ignore: Take no action when the exception occurs. - - warn: Print a `RuntimeWarning` (via the Python `warnings` module). - - raise: Raise a `FloatingPointError`. + - warn: Print a :exc:`RuntimeWarning` (via the Python `warnings` module). + - raise: Raise a :exc:`FloatingPointError`. - call: Call a function specified using the `seterrcall` function. - print: Print a warning directly to ``stdout``. - log: Record error in a Log object specified by `seterrcall`. diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index 4bbcf9ba93e0..937d0ff37d2d 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -426,7 +426,7 @@ def capitalize(a): Return a copy of `a` with only the first character of each element capitalized. - Calls `str.capitalize` element-wise. + Calls :meth:`str.capitalize` element-wise. For 8-bit strings, this method is locale-dependent. @@ -469,7 +469,7 @@ def center(a, width, fillchar=' '): Return a copy of `a` with its elements centered in a string of length `width`. - Calls `str.center` element-wise. + Calls :meth:`str.center` element-wise. Parameters ---------- @@ -526,7 +526,7 @@ def count(a, sub, start=0, end=None): Returns an array with the number of non-overlapping occurrences of substring `sub` in the range [`start`, `end`]. - Calls `str.count` element-wise. + Calls :meth:`str.count` element-wise. Parameters ---------- @@ -573,7 +573,7 @@ def _code_dispatcher(a, encoding=None, errors=None): @array_function_dispatch(_code_dispatcher) def decode(a, encoding=None, errors=None): r""" - Calls ``bytes.decode`` element-wise. + Calls :meth:`bytes.decode` element-wise. The set of available codecs comes from the Python standard library, and may be extended at runtime. For more information, see the @@ -619,11 +619,11 @@ def decode(a, encoding=None, errors=None): @array_function_dispatch(_code_dispatcher) def encode(a, encoding=None, errors=None): """ - Calls `str.encode` element-wise. + Calls :meth:`str.encode` element-wise. The set of available codecs comes from the Python standard library, - and may be extended at runtime. For more information, see the codecs - module. + and may be extended at runtime. For more information, see the + :mod:`codecs` module. Parameters ---------- @@ -662,7 +662,7 @@ def endswith(a, suffix, start=0, end=None): Returns a boolean array which is `True` where the string element in `a` ends with `suffix`, otherwise `False`. - Calls `str.endswith` element-wise. + Calls :meth:`str.endswith` element-wise. Parameters ---------- @@ -710,7 +710,7 @@ def expandtabs(a, tabsize=8): Return a copy of each string element where all tab characters are replaced by one or more spaces. - Calls `str.expandtabs` element-wise. + Calls :meth:`str.expandtabs` element-wise. Return a copy of each string element where all tab characters are replaced by one or more spaces, depending on the current column @@ -746,7 +746,7 @@ def find(a, sub, start=0, end=None): For each element, return the lowest index in the string where substring `sub` is found. - Calls `str.find` element-wise. + Calls :meth:`str.find` element-wise. For each element, return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the @@ -785,9 +785,9 @@ def find(a, sub, start=0, end=None): @array_function_dispatch(_count_dispatcher) def index(a, sub, start=0, end=None): """ - Like `find`, but raises `ValueError` when the substring is not found. + Like `find`, but raises :exc:`ValueError` when the substring is not found. - Calls `str.index` element-wise. + Calls :meth:`str.index` element-wise. Parameters ---------- @@ -823,7 +823,7 @@ def isalnum(a): Returns true for each element if all characters in the string are alphanumeric and there is at least one character, false otherwise. - Calls `str.isalnum` element-wise. + Calls :meth:`str.isalnum` element-wise. For 8-bit strings, this method is locale-dependent. @@ -849,7 +849,7 @@ def isalpha(a): Returns true for each element if all characters in the string are alphabetic and there is at least one character, false otherwise. - Calls `str.isalpha` element-wise. + Calls :meth:`str.isalpha` element-wise. For 8-bit strings, this method is locale-dependent. @@ -875,7 +875,7 @@ def isdigit(a): Returns true for each element if all characters in the string are digits and there is at least one character, false otherwise. - Calls `str.isdigit` element-wise. + Calls :meth:`str.isdigit` element-wise. For 8-bit strings, this method is locale-dependent. @@ -911,7 +911,7 @@ def islower(a): string are lowercase and there is at least one cased character, false otherwise. - Calls `str.islower` element-wise. + Calls :meth:`str.islower` element-wise. For 8-bit strings, this method is locale-dependent. @@ -938,7 +938,7 @@ def isspace(a): characters in the string and there is at least one character, false otherwise. - Calls `str.isspace` element-wise. + Calls :meth:`str.isspace` element-wise. For 8-bit strings, this method is locale-dependent. @@ -964,7 +964,7 @@ def istitle(a): Returns true for each element if the element is a titlecased string and there is at least one character, false otherwise. - Call `str.istitle` element-wise. + Call :meth:`str.istitle` element-wise. For 8-bit strings, this method is locale-dependent. @@ -991,7 +991,7 @@ def isupper(a): string are uppercase and there is at least one character, false otherwise. - Call `str.isupper` element-wise. + Call :meth:`str.isupper` element-wise. For 8-bit strings, this method is locale-dependent. @@ -1031,7 +1031,7 @@ def join(sep, seq): Return a string which is the concatenation of the strings in the sequence `seq`. - Calls `str.join` element-wise. + Calls :meth:`str.join` element-wise. Parameters ---------- @@ -1071,7 +1071,7 @@ def ljust(a, width, fillchar=' '): Return an array with the elements of `a` left-justified in a string of length `width`. - Calls `str.ljust` element-wise. + Calls :meth:`str.ljust` element-wise. Parameters ---------- @@ -1106,7 +1106,7 @@ def lower(a): """ Return an array with the elements converted to lowercase. - Call `str.lower` element-wise. + Call :meth:`str.lower` element-wise. For 8-bit strings, this method is locale-dependent. @@ -1146,7 +1146,7 @@ def lstrip(a, chars=None): For each element in `a`, return a copy with the leading characters removed. - Calls `str.lstrip` element-wise. + Calls :meth:`str.lstrip` element-wise. Parameters ---------- @@ -1204,7 +1204,7 @@ def partition(a, sep): """ Partition each element in `a` around `sep`. - Calls `str.partition` element-wise. + Calls :meth:`str.partition` element-wise. For each element in `a`, split the element as the first occurrence of `sep`, and return 3 strings containing the part @@ -1245,7 +1245,7 @@ def replace(a, old, new, count=None): For each element in `a`, return a copy of the string with all occurrences of substring `old` replaced by `new`. - Calls `str.replace` element-wise. + Calls :meth:`str.replace` element-wise. Parameters ---------- @@ -1287,7 +1287,7 @@ def rfind(a, sub, start=0, end=None): where substring `sub` is found, such that `sub` is contained within [`start`, `end`]. - Calls `str.rfind` element-wise. + Calls :meth:`str.rfind` element-wise. Parameters ---------- @@ -1316,10 +1316,10 @@ def rfind(a, sub, start=0, end=None): @array_function_dispatch(_count_dispatcher) def rindex(a, sub, start=0, end=None): """ - Like `rfind`, but raises `ValueError` when the substring `sub` is + Like `rfind`, but raises :exc:`ValueError` when the substring `sub` is not found. - Calls `str.rindex` element-wise. + Calls :meth:`str.rindex` element-wise. Parameters ---------- @@ -1349,7 +1349,7 @@ def rjust(a, width, fillchar=' '): Return an array with the elements of `a` right-justified in a string of length `width`. - Calls `str.rjust` element-wise. + Calls :meth:`str.rjust` element-wise. Parameters ---------- @@ -1384,7 +1384,7 @@ def rpartition(a, sep): """ Partition (split) each element around the right-most separator. - Calls `str.rpartition` element-wise. + Calls :meth:`str.rpartition` element-wise. For each element in `a`, split the element as the last occurrence of `sep`, and return 3 strings containing the part @@ -1425,7 +1425,7 @@ def rsplit(a, sep=None, maxsplit=None): For each element in `a`, return a list of the words in the string, using `sep` as the delimiter string. - Calls `str.rsplit` element-wise. + Calls :meth:`str.rsplit` element-wise. Except for splitting from the right, `rsplit` behaves like `split`. @@ -1467,7 +1467,7 @@ def rstrip(a, chars=None): For each element in `a`, return a copy with the trailing characters removed. - Calls `str.rstrip` element-wise. + Calls :meth:`str.rstrip` element-wise. Parameters ---------- @@ -1512,7 +1512,7 @@ def split(a, sep=None, maxsplit=None): For each element in `a`, return a list of the words in the string, using `sep` as the delimiter string. - Calls `str.split` element-wise. + Calls :meth:`str.split` element-wise. Parameters ---------- @@ -1551,7 +1551,7 @@ def splitlines(a, keepends=None): For each element in `a`, return a list of the lines in the element, breaking at line boundaries. - Calls `str.splitlines` element-wise. + Calls :meth:`str.splitlines` element-wise. Parameters ---------- @@ -1585,7 +1585,7 @@ def startswith(a, prefix, start=0, end=None): Returns a boolean array which is `True` where the string element in `a` starts with `prefix`, otherwise `False`. - Calls `str.startswith` element-wise. + Calls :meth:`str.startswith` element-wise. Parameters ---------- @@ -1617,7 +1617,7 @@ def strip(a, chars=None): For each element in `a`, return a copy with the leading and trailing characters removed. - Calls `str.strip` element-wise. + Calls :meth:`str.strip` element-wise. Parameters ---------- @@ -1662,7 +1662,7 @@ def swapcase(a): Return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa. - Calls `str.swapcase` element-wise. + Calls :meth:`str.swapcase` element-wise. For 8-bit strings, this method is locale-dependent. @@ -1702,7 +1702,7 @@ def title(a): Title case words start with uppercase characters, all remaining cased characters are lowercase. - Calls `str.title` element-wise. + Calls :meth:`str.title` element-wise. For 8-bit strings, this method is locale-dependent. @@ -1746,7 +1746,7 @@ def translate(a, table, deletechars=None): removed, and the remaining characters have been mapped through the given translation table. - Calls `str.translate` element-wise. + Calls :meth:`str.translate` element-wise. Parameters ---------- @@ -1780,7 +1780,7 @@ def upper(a): """ Return an array with the elements converted to uppercase. - Calls `str.upper` element-wise. + Calls :meth:`str.upper` element-wise. For 8-bit strings, this method is locale-dependent. @@ -1819,7 +1819,7 @@ def zfill(a, width): """ Return the numeric string left-filled with zeros - Calls `str.zfill` element-wise. + Calls :meth:`str.zfill` element-wise. Parameters ---------- @@ -1851,7 +1851,7 @@ def isnumeric(a): For each element, return True if there are only numeric characters in the element. - Calls `str.isnumeric` element-wise. + Calls :meth:`str.isnumeric` element-wise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. ``U+2155, @@ -1888,7 +1888,7 @@ def isdecimal(a): For each element, return True if there are only decimal characters in the element. - Calls `str.isdecimal` element-wise. + Calls :meth:`str.isdecimal` element-wise. Decimal characters include digit characters, and all characters that can be used to form decimal-radix numbers, @@ -2306,7 +2306,7 @@ def decode(self, encoding=None, errors=None): def encode(self, encoding=None, errors=None): """ - Calls `str.encode` element-wise. + Calls :meth:`str.encode` element-wise. See Also -------- @@ -2353,7 +2353,7 @@ def find(self, sub, start=0, end=None): def index(self, sub, start=0, end=None): """ - Like `find`, but raises `ValueError` when the substring is not found. + Like `find`, but raises :exc:`ValueError` when the substring is not found. See Also -------- @@ -2536,7 +2536,7 @@ def rfind(self, sub, start=0, end=None): def rindex(self, sub, start=0, end=None): """ - Like `rfind`, but raises `ValueError` when the substring `sub` is + Like `rfind`, but raises :exc:`ValueError` when the substring `sub` is not found. See Also diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 4bdfe05daa63..c5586067cb59 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1897,7 +1897,7 @@ def isscalar(element): | builtin string and buffer objects | ``True`` | ``True`` | +--------------------------------------+---------------+-------------------+ | other builtin objects, like | ``False`` | ``True`` | - | `pathlib.Path`, `Exception`, | | | + | `pathlib.Path`, :exc:`Exception`, | | | | the result of `re.compile` | | | +--------------------------------------+---------------+-------------------+ | third-party objects like | ``False`` | ``True`` | @@ -1907,8 +1907,8 @@ def isscalar(element): +--------------------------------------+---------------+-------------------+ | other numpy arrays | ``False`` | ``False`` | +--------------------------------------+---------------+-------------------+ - | `list`, `tuple`, and other sequence | ``False`` | ``False`` | - | objects | | | + | :class:`list`, :class:`tuple`, | ``False`` | ``False`` | + | and other sequence objects | | | +--------------------------------------+---------------+-------------------+ Examples @@ -2310,7 +2310,7 @@ def isclose(a, b, rtol=1.e-5, atol=1.e-8, equal_nan=False): for `atol` will result in `False` if either `a` or `b` is zero. `isclose` is not defined for non-numeric data types. - `bool` is considered a numeric data-type for this purpose. + :class:`bool` is considered a numeric data-type for this purpose. Examples -------- diff --git a/numpy/fft/__init__.py b/numpy/fft/__init__.py index ea51a6ba119e..fd5e47580a54 100644 --- a/numpy/fft/__init__.py +++ b/numpy/fft/__init__.py @@ -4,7 +4,7 @@ .. currentmodule:: numpy.fft -The SciPy module :mod:`scipy.fft` is a more comprehensive superset +The SciPy module `scipy.fft` is a more comprehensive superset of ``numpy.fft``, which includes only a basic set of routines. Standard FFTs @@ -126,7 +126,7 @@ `numpy.fft` promotes ``float32`` and ``complex64`` arrays to ``float64`` and ``complex128`` arrays respectively. For an FFT implementation that does not -promote input arrays, see :mod:`scipy.fftpack`. +promote input arrays, see `scipy.fftpack`. Normalization ------------- diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py index 56bffa37812a..c8ee74d7e615 100644 --- a/numpy/lib/stride_tricks.py +++ b/numpy/lib/stride_tricks.py @@ -177,9 +177,9 @@ def sliding_window_view(x, window_shape, axis=None, *, For many applications using a sliding window view can be convenient, but potentially very slow. Often specialized solutions exist, for example: - - :func:`scipy.signal.fftconvolve` + - `scipy.signal.fftconvolve` - - filtering functions in :mod:`scipy.ndimage` + - filtering functions in `scipy.ndimage` - moving window functions provided by `bottleneck `_. diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 6f49b4c28526..90e22676ac79 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -192,7 +192,7 @@ def deprecate(*args, **kwargs): This function may also be used as a decorator. .. deprecated:: 2.0 - Use `warn` with `DeprecationWarning` instead. + Use `warn` with :exc:`DeprecationWarning` instead. Parameters ---------- @@ -253,7 +253,7 @@ def deprecate_with_doc(msg): Deprecates a function and includes the deprecation in its docstring. .. deprecated:: 2.0 - Use `warn` with `DeprecationWarning` instead. + Use `warn` with :exc:`DeprecationWarning` instead. This function is used as a decorator. It returns an object that can be used to issue a DeprecationWarning, by passing the to-be decorated @@ -262,7 +262,7 @@ def deprecate_with_doc(msg): See Also -------- - deprecate : Decorate a function such that it issues a `DeprecationWarning` + deprecate : Decorate a function such that it issues a :exc:`DeprecationWarning` Parameters ---------- diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py index 33e89e665c5d..f0241fcdef92 100644 --- a/numpy/polynomial/chebyshev.py +++ b/numpy/polynomial/chebyshev.py @@ -519,7 +519,7 @@ def chebfromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - in Chebyshev form, where the `r_n` are the roots specified in `roots`. + in Chebyshev form, where the :math:`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 diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index 63791ff61cc7..62ba10d0220c 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -262,7 +262,7 @@ def hermfromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - in Hermite form, where the `r_n` are the roots specified in `roots`. + in Hermite form, where the :math:`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 diff --git a/numpy/polynomial/hermite_e.py b/numpy/polynomial/hermite_e.py index e46c43a3647a..9b810971dde3 100644 --- a/numpy/polynomial/hermite_e.py +++ b/numpy/polynomial/hermite_e.py @@ -261,7 +261,7 @@ def hermefromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - in HermiteE form, where the `r_n` are the roots specified in `roots`. + in HermiteE form, where the :math:`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 diff --git a/numpy/polynomial/laguerre.py b/numpy/polynomial/laguerre.py index 1c715cb33e7c..48a281dd892f 100644 --- a/numpy/polynomial/laguerre.py +++ b/numpy/polynomial/laguerre.py @@ -256,7 +256,7 @@ def lagfromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - in Laguerre form, where the `r_n` are the roots specified in `roots`. + in Laguerre form, where the :math:`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 diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py index b9cac061d1c9..3a0a1a5d53c9 100644 --- a/numpy/polynomial/legendre.py +++ b/numpy/polynomial/legendre.py @@ -272,7 +272,7 @@ def legfromroots(roots): .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), - in Legendre form, where the `r_n` are the roots specified in `roots`. + in Legendre form, where the :math:`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 diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index 5a204b7d33cc..c776942c2f31 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 :math:`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