summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2020-10-13 17:26:20 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2020-10-17 18:05:12 +0200
commitfdf30fb70821462fc636e11c361688e46cfeaccf (patch)
tree490121cbf808d55f0e98e82c6cd2942354e07e3d
parent9e732c85a259c500088df39e5492b014b56ef5da (diff)
downloadnumpy-fdf30fb70821462fc636e11c361688e46cfeaccf.tar.gz
DOC: Fixed some docstring formatting
-rw-r--r--numpy/typing/__init__.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/numpy/typing/__init__.py b/numpy/typing/__init__.py
index 5c6e5df99..2738da071 100644
--- a/numpy/typing/__init__.py
+++ b/numpy/typing/__init__.py
@@ -111,39 +111,41 @@ else:
@final # Dissallow the creation of arbitrary `NBitBase` subclasses
class NBitBase:
"""
- An object representing `number` precision during static type checking.
+ An object representing `numpy.number` precision during static type checking.
Used exclusively for the purpose static type checking, `NBitBase`
represents the base of a hierachieral set of subclasses.
Each subsequent subclass is herein used for representing a lower level
- of precision, _e.g._ `64Bit > 32Bit > 16Bit`.
+ of precision, *e.g.* ``64Bit > 32Bit > 16Bit``.
Examples
--------
Below is a typical usage example: `NBitBase` is herein used for annotating a
function that takes a float and integer of arbitrary precision as arguments
and returns a new float of whichever precision is largest
- (_e.g._ `np.float16 + np.int64 -> np.float64`).
+ (*e.g.* ``np.float16 + np.int64 -> np.float64``).
- >>> from typing import TypeVar, TYPE_CHECKING
- >>> import numpy as np
- >>> import numpy.typing as npt
+ .. code-block:: python
- >>> T = TypeVar("T", bound=npt.NBitBase)
+ >>> from typing import TypeVar, TYPE_CHECKING
+ >>> import numpy as np
+ >>> import numpy.typing as npt
- >>> def add(a: "np.floating[T]", b: "np.integer[T]") -> "np.floating[T]":
- ... return a + b
+ >>> T = TypeVar("T", bound=npt.NBitBase)
- >>> a = np.float16()
- >>> b = np.int64()
- >>> out = add(a, b)
+ >>> def add(a: "np.floating[T]", b: "np.integer[T]") -> "np.floating[T]":
+ ... return a + b
- >>> if TYPE_CHECKING:
- ... reveal_locals()
- ... # note: Revealed local types are:
- ... # note: a: numpy.floating[numpy.typing._16Bit*]
- ... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
- ... # note: out: numpy.floating[numpy.typing._64Bit*]
+ >>> a = np.float16()
+ >>> b = np.int64()
+ >>> out = add(a, b)
+
+ >>> if TYPE_CHECKING:
+ ... reveal_locals()
+ ... # note: Revealed local types are:
+ ... # note: a: numpy.floating[numpy.typing._16Bit*]
+ ... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
+ ... # note: out: numpy.floating[numpy.typing._64Bit*]
"""