diff options
-rw-r--r-- | doc/source/reference/arrays.classes.rst | 6 | ||||
-rw-r--r-- | numpy/doc/dispatch.py | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/doc/source/reference/arrays.classes.rst b/doc/source/reference/arrays.classes.rst index addc403b8..a91215476 100644 --- a/doc/source/reference/arrays.classes.rst +++ b/doc/source/reference/arrays.classes.rst @@ -169,7 +169,7 @@ NumPy provides several hooks that classes can customize: - ``func`` is an arbitrary callable exposed by NumPy's public API, which was called in the form ``func(*args, **kwargs)``. - - ``types`` is a `collection <https://docs.python.org/3/library/collections.abc.html#collections.abc.Collection>`_ + - ``types`` is a `collection <collections.abc.Collection>`_ of unique argument types from the original NumPy function call that implement ``__array_function__``. - The tuple ``args`` and dict ``kwargs`` are directly passed on from the @@ -179,7 +179,7 @@ NumPy provides several hooks that classes can customize: provides all argument types with an ``'__array_function__'`` attribute. This allows implementors to quickly identify cases where they should defer to ``__array_function__`` implementations on other arguments. - Implementaitons should not rely on the iteration order of ``types``. + Implementations should not rely on the iteration order of ``types``. Most implementations of ``__array_function__`` will start with two checks: @@ -255,7 +255,7 @@ NumPy provides several hooks that classes can customize: - If all ``__array_function__`` methods return ``NotImplemented``, NumPy will raise ``TypeError``. - If no ``__array_function__`` methods exist, NumPy will default to calling + If no ``__array_function__`` methods exists, NumPy will default to calling its own implementation, intended for use on NumPy arrays. This case arises, for example, when all array-like arguments are Python numbers or lists. (NumPy arrays do have a ``__array_function__`` method, given below, but it diff --git a/numpy/doc/dispatch.py b/numpy/doc/dispatch.py index f592d4ffd..313167005 100644 --- a/numpy/doc/dispatch.py +++ b/numpy/doc/dispatch.py @@ -214,6 +214,8 @@ to add functions to ``HANDLED_FUNCTIONS``. ... Now we write implementations of numpy functions for ``DiagonalArray``. +For completeness, to support the usage ``arr.sum()`` add a method ``sum`` that +calls ``numpy.sum(self)``, and the same for ``mean``. >>> @implements(np.sum) ... def sum(a, axis=None, out=None): @@ -233,9 +235,6 @@ Now we write implementations of numpy functions for ``DiagonalArray``. >>> np.mean(arr) 0.2 -For completeness, to support the usage ``arr.sum()`` add a method ``sum`` that -calls ``numpy.sum(self)``, and the same for ``mean``. - If the user tries to use any numpy functions not included in ``HANDLED_FUNCTIONS``, a ``TypeError`` will be raised by numpy, indicating that this operation is not supported. For example, concatenating two |