summaryrefslogtreecommitdiff
path: root/numpy/doc/dispatch.py
diff options
context:
space:
mode:
authorDan Allan <dallan@bnl.gov>2019-07-14 10:04:14 -0500
committerDan Allan <dallan@bnl.gov>2019-07-14 10:04:14 -0500
commit3b27713a2c2d432a2ece6344417df93422d3f96c (patch)
tree8a9bb67a5b8df1849e8f322128f0d819cb8e9c1c /numpy/doc/dispatch.py
parent54911b6365bd4931055cc134dd10c9b0639d07dc (diff)
downloadnumpy-3b27713a2c2d432a2ece6344417df93422d3f96c.tar.gz
Improve illustartion of unsupported args.
Diffstat (limited to 'numpy/doc/dispatch.py')
-rw-r--r--numpy/doc/dispatch.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/numpy/doc/dispatch.py b/numpy/doc/dispatch.py
index 313167005..09a3e5134 100644
--- a/numpy/doc/dispatch.py
+++ b/numpy/doc/dispatch.py
@@ -218,14 +218,12 @@ 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):
+... def sum(a):
... "Implementation of np.sum for DiagonalArray objects"
-... if axis is not None:
-... raise TypeError("DiagonalArrays cannot be summed along one axis.")
... return arr._i * arr._N
...
>>> @implements(np.mean)
-... def sum(a, axis=None, out=None):
+... def sum(a):
... "Implementation of np.mean for DiagonalArray objects"
... return arr._i / arr._N
...
@@ -244,8 +242,14 @@ supported.
>>> np.concatenate([arr, arr])
TypeError: no implementation found for 'numpy.concatenate' on types that implement __array_function__: [<class '__main__.DiagonalArray'>]
-The user always has the option of converting to a normal
-``numpy.ndarray`` with :func:`numpy.asarray` and using standard numpy from there.
+Additionally, our implementations of ``sum`` and ``mean`` do not accept the
+optional arguments that numpy's implementation does.
+
+>>> np.sum(arr, axis=0)
+TypeError: sum() got an unexpected keyword argument 'axis'
+
+The user always has the option of converting to a normal ``numpy.ndarray`` with
+:func:`numpy.asarray` and using standard numpy from there.
>>> np.concatenate([np.asarray(arr), np.asarray(arr)])
array([[1., 0., 0., 0., 0.],