@@ -1812,7 +1812,7 @@ def sum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
1812
1812
If the default value is passed, then `keepdims` will not be
1813
1813
passed through to the `sum` method of sub-classes of
1814
1814
`ndarray`, however any non-default value will be. If the
1815
- sub-classes `sum` method does not implement `keepdims` any
1815
+ sub-class' method does not implement `keepdims` any
1816
1816
exceptions will be raised.
1817
1817
1818
1818
Returns
@@ -1966,7 +1966,7 @@ def any(a, axis=None, out=None, keepdims=np._NoValue):
1966
1966
If the default value is passed, then `keepdims` will not be
1967
1967
passed through to the `any` method of sub-classes of
1968
1968
`ndarray`, however any non-default value will be. If the
1969
- sub-classes `sum` method does not implement `keepdims` any
1969
+ sub-class' method does not implement `keepdims` any
1970
1970
exceptions will be raised.
1971
1971
1972
1972
Returns
@@ -2051,7 +2051,7 @@ def all(a, axis=None, out=None, keepdims=np._NoValue):
2051
2051
If the default value is passed, then `keepdims` will not be
2052
2052
passed through to the `all` method of sub-classes of
2053
2053
`ndarray`, however any non-default value will be. If the
2054
- sub-classes `sum` method does not implement `keepdims` any
2054
+ sub-class' method does not implement `keepdims` any
2055
2055
exceptions will be raised.
2056
2056
2057
2057
Returns
@@ -2178,7 +2178,7 @@ def cumproduct(a, axis=None, dtype=None, out=None):
2178
2178
return _wrapfunc (a , 'cumprod' , axis = axis , dtype = dtype , out = out )
2179
2179
2180
2180
2181
- def ptp (a , axis = None , out = None ):
2181
+ def ptp (a , axis = None , out = None , keepdims = np . _NoValue ):
2182
2182
"""
2183
2183
Range of values (maximum - minimum) along an axis.
2184
2184
@@ -2188,14 +2188,31 @@ def ptp(a, axis=None, out=None):
2188
2188
----------
2189
2189
a : array_like
2190
2190
Input values.
2191
- axis : int, optional
2191
+ axis : None or int or tuple of ints , optional
2192
2192
Axis along which to find the peaks. By default, flatten the
2193
- array.
2193
+ array. `axis` may be negative, in
2194
+ which case it counts from the last to the first axis.
2195
+
2196
+ .. versionadded:: 1.15.0
2197
+
2198
+ If this is a tuple of ints, a reduction is performed on multiple
2199
+ axes, instead of a single axis or all the axes as before.
2194
2200
out : array_like
2195
2201
Alternative output array in which to place the result. It must
2196
2202
have the same shape and buffer length as the expected output,
2197
2203
but the type of the output values will be cast if necessary.
2198
2204
2205
+ keepdims : bool, optional
2206
+ If this is set to True, the axes which are reduced are left
2207
+ in the result as dimensions with size one. With this option,
2208
+ the result will broadcast correctly against the input array.
2209
+
2210
+ If the default value is passed, then `keepdims` will not be
2211
+ passed through to the `ptp` method of sub-classes of
2212
+ `ndarray`, however any non-default value will be. If the
2213
+ sub-class' method does not implement `keepdims` any
2214
+ exceptions will be raised.
2215
+
2199
2216
Returns
2200
2217
-------
2201
2218
ptp : ndarray
@@ -2216,7 +2233,17 @@ def ptp(a, axis=None, out=None):
2216
2233
array([1, 1])
2217
2234
2218
2235
"""
2219
- return _wrapfunc (a , 'ptp' , axis = axis , out = out )
2236
+ kwargs = {}
2237
+ if keepdims is not np ._NoValue :
2238
+ kwargs ['keepdims' ] = keepdims
2239
+ if type (a ) is not mu .ndarray :
2240
+ try :
2241
+ ptp = a .ptp
2242
+ except AttributeError :
2243
+ pass
2244
+ else :
2245
+ return ptp (axis = axis , out = out , ** kwargs )
2246
+ return _methods ._ptp (a , axis = axis , out = out , ** kwargs )
2220
2247
2221
2248
2222
2249
def amax (a , axis = None , out = None , keepdims = np ._NoValue ):
@@ -2248,7 +2275,7 @@ def amax(a, axis=None, out=None, keepdims=np._NoValue):
2248
2275
If the default value is passed, then `keepdims` will not be
2249
2276
passed through to the `amax` method of sub-classes of
2250
2277
`ndarray`, however any non-default value will be. If the
2251
- sub-classes `sum` method does not implement `keepdims` any
2278
+ sub-class' method does not implement `keepdims` any
2252
2279
exceptions will be raised.
2253
2280
2254
2281
Returns
@@ -2349,7 +2376,7 @@ def amin(a, axis=None, out=None, keepdims=np._NoValue):
2349
2376
If the default value is passed, then `keepdims` will not be
2350
2377
passed through to the `amin` method of sub-classes of
2351
2378
`ndarray`, however any non-default value will be. If the
2352
- sub-classes `sum` method does not implement `keepdims` any
2379
+ sub-class' method does not implement `keepdims` any
2353
2380
exceptions will be raised.
2354
2381
2355
2382
Returns
@@ -2491,7 +2518,7 @@ def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
2491
2518
If the default value is passed, then `keepdims` will not be
2492
2519
passed through to the `prod` method of sub-classes of
2493
2520
`ndarray`, however any non-default value will be. If the
2494
- sub-classes `sum` method does not implement `keepdims` any
2521
+ sub-class' method does not implement `keepdims` any
2495
2522
exceptions will be raised.
2496
2523
2497
2524
Returns
@@ -2890,7 +2917,7 @@ def mean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
2890
2917
If the default value is passed, then `keepdims` will not be
2891
2918
passed through to the `mean` method of sub-classes of
2892
2919
`ndarray`, however any non-default value will be. If the
2893
- sub-classes `sum` method does not implement `keepdims` any
2920
+ sub-class' method does not implement `keepdims` any
2894
2921
exceptions will be raised.
2895
2922
2896
2923
Returns
@@ -2997,7 +3024,7 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue):
2997
3024
If the default value is passed, then `keepdims` will not be
2998
3025
passed through to the `std` method of sub-classes of
2999
3026
`ndarray`, however any non-default value will be. If the
3000
- sub-classes `sum` method does not implement `keepdims` any
3027
+ sub-class' method does not implement `keepdims` any
3001
3028
exceptions will be raised.
3002
3029
3003
3030
Returns
@@ -3116,7 +3143,7 @@ def var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue):
3116
3143
If the default value is passed, then `keepdims` will not be
3117
3144
passed through to the `var` method of sub-classes of
3118
3145
`ndarray`, however any non-default value will be. If the
3119
- sub-classes `sum` method does not implement `keepdims` any
3146
+ sub-class' method does not implement `keepdims` any
3120
3147
exceptions will be raised.
3121
3148
3122
3149
Returns
0 commit comments