Skip to content

Commit d090de9

Browse files
authored
Add support of missing arguments in dpnp.amax and dpnp.amin (#1639)
* Added support of missing arguments in amax and amin functions * Updated See also links * Updated alias reference
1 parent 9575363 commit d090de9

File tree

4 files changed

+30
-69
lines changed

4 files changed

+30
-69
lines changed

dpnp/dpnp_iface_mathematical.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,11 +1477,11 @@ def maximum(
14771477
--------
14781478
:obj:`dpnp.minimum` : Element-wise minimum of two arrays, propagates NaNs.
14791479
:obj:`dpnp.fmax` : Element-wise maximum of two arrays, ignores NaNs.
1480-
:obj:`dpnp.amax` : The maximum value of an array along a given axis, propagates NaNs.
1481-
:obj:`dpnp.nanmax` : The maximum value of an array along a given axis, ignores NaNs.
1482-
:obj:`dpnp.fmax` : Element-wise maximum of two arrays, ignores NaNs.
1483-
:obj:`dpnp.amax` : The maximum value of an array along a given axis, propagates NaNs.
1480+
:obj:`dpnp.max` : The maximum value of an array along a given axis, propagates NaNs.
14841481
:obj:`dpnp.nanmax` : The maximum value of an array along a given axis, ignores NaNs.
1482+
:obj:`dpnp.fmin` : Element-wise minimum of two arrays, ignores NaNs.
1483+
:obj:`dpnp.min` : The minimum value of an array along a given axis, propagates NaNs.
1484+
:obj:`dpnp.nanmin` : The minimum value of an array along a given axis, ignores NaNs.
14851485
14861486
Examples
14871487
--------
@@ -1556,11 +1556,11 @@ def minimum(
15561556
--------
15571557
:obj:`dpnp.maximum` : Element-wise maximum of two arrays, propagates NaNs.
15581558
:obj:`dpnp.fmin` : Element-wise minimum of two arrays, ignores NaNs.
1559-
:obj:`dpnp.amin` : The minimum value of an array along a given axis, propagates NaNs.
1560-
:obj:`dpnp.nanmin` : The minimum value of an array along a given axis, ignores NaNs.
1561-
:obj:`dpnp.fmin` : Element-wise minimum of two arrays, ignores NaNs.
1562-
:obj:`dpnp.amin` : The minimum value of an array along a given axis, propagates NaNs.
1559+
:obj:`dpnp.min` : The minimum value of an array along a given axis, propagates NaNs.
15631560
:obj:`dpnp.nanmin` : The minimum value of an array along a given axis, ignores NaNs.
1561+
:obj:`dpnp.fmax` : Element-wise maximum of two arrays, ignores NaNs.
1562+
:obj:`dpnp.max` : The maximum value of an array along a given axis, propagates NaNs.
1563+
:obj:`dpnp.nanmax` : The maximum value of an array along a given axis, ignores NaNs.
15641564
15651565
Examples
15661566
--------

dpnp/dpnp_iface_searching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def argmax(a, axis=None, out=None, *, keepdims=False):
8282
--------
8383
:obj:`dpnp.ndarray.argmax` : Equivalent function.
8484
:obj:`dpnp.argmin` : Returns the indices of the minimum values along an axis.
85-
:obj:`dpnp.amax` : The maximum value along a given axis.
85+
:obj:`dpnp.max` : The maximum value along a given axis.
8686
:obj:`dpnp.unravel_index` : Convert a flat index into an index tuple.
8787
:obj:`dpnp.take_along_axis` : Apply ``np.expand_dims(index_array, axis)``
8888
from argmax to an array as if by calling max.
@@ -162,7 +162,7 @@ def argmin(a, axis=None, out=None, *, keepdims=False):
162162
--------
163163
:obj:`dpnp.ndarray.argmin` : Equivalent function.
164164
:obj:`dpnp.argmax` : Returns the indices of the maximum values along an axis.
165-
:obj:`dpnp.amin` : The minimum value along a given axis.
165+
:obj:`dpnp.min` : The minimum value along a given axis.
166166
:obj:`dpnp.unravel_index` : Convert a flat index into an index tuple.
167167
:obj:`dpnp.take_along_axis` : Apply ``np.expand_dims(index_array, axis)``
168168
from argmin to an array as if by calling min.

dpnp/dpnp_iface_statistics.py

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,63 +66,40 @@
6666
]
6767

6868

69-
def amax(input, axis=None, out=None):
69+
def amax(a, axis=None, out=None, keepdims=False, initial=None, where=True):
7070
"""
7171
Return the maximum of an array or maximum along an axis.
7272
73-
For full documentation refer to :obj:`numpy.amax`.
73+
`amax` is an alias of :obj:`dpnp.max`.
7474
7575
See Also
7676
--------
77-
:obj:`dpnp.amin` : The minimum value of an array along a given axis,
78-
propagating any NaNs.
79-
:obj:`dpnp.nanmax` : The maximum value of an array along a given axis,
80-
ignoring any NaNs.
81-
:obj:`dpnp.maximum` : Element-wise maximum of two arrays,
82-
propagating any NaNs.
83-
:obj:`dpnp.fmax` : Element-wise maximum of two arrays, ignoring any NaNs.
84-
:obj:`dpnp.argmax` : Return the indices of the maximum values.
85-
:obj:`dpnp.nanmin` : Return minimum of an array or minimum along an axis,
86-
ignoring any NaNs.
87-
:obj:`dpnp.minimum` : Element-wise minimum of array elements.
88-
:obj:`dpnp.fmin` : Element-wise minimum of array elements.
89-
90-
Notes
91-
-----
92-
This function works exactly the same as :obj:`dpnp.max`.
77+
:obj:`dpnp.max` : alias of this function
78+
:obj:`dpnp.ndarray.max` : equivalent method
9379
9480
"""
95-
return max(input, axis=axis, out=out)
81+
82+
return max(
83+
a, axis=axis, out=out, keepdims=keepdims, initial=initial, where=where
84+
)
9685

9786

98-
def amin(input, axis=None, out=None):
87+
def amin(a, axis=None, out=None, keepdims=False, initial=None, where=True):
9988
"""
10089
Return the minimum of an array or minimum along an axis.
10190
102-
For full documentation refer to :obj:`numpy.amin`.
91+
`amin` is an alias of :obj:`dpnp.min`.
10392
10493
See Also
10594
--------
106-
:obj:`dpnp.amax` : The maximum value of an array along a given axis,
107-
propagating any NaNs.
108-
:obj:`dpnp.nanmin` : Return minimum of an array or minimum along an axis,
109-
ignoring any NaNs.
110-
:obj:`dpnp.minimum` : Element-wise minimum of array elements.
111-
:obj:`dpnp.fmin` : Element-wise minimum of array elements.
112-
:obj:`dpnp.argmin` : Return the indices of the minimum values.
113-
:obj:`dpnp.nanmax` : The maximum value of an array along a given axis,
114-
ignoring any NaNs.
115-
:obj:`dpnp.maximum` : Element-wise maximum of two arrays,
116-
propagating any NaNs.
117-
:obj:`dpnp.fmax` : Element-wise maximum of two arrays, ignoring any NaNs.
118-
119-
Notes
120-
-----
121-
This function works exactly the same as :obj:`dpnp.min`.
95+
:obj:`dpnp.min` : alias of this function
96+
:obj:`dpnp.ndarray.min` : equivalent method
12297
12398
"""
12499

125-
return min(input, axis=axis, out=out)
100+
return min(
101+
a, axis=axis, out=out, keepdims=keepdims, initial=initial, where=where
102+
)
126103

127104

128105
def average(x1, axis=None, weights=None, returned=False):

tests/test_amin_amax.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from .helper import get_all_dtypes
88

99

10+
@pytest.mark.parametrize("func", ["amax", "amin"])
11+
@pytest.mark.parametrize("keepdims", [True, False])
1012
@pytest.mark.parametrize("dtype", get_all_dtypes())
11-
def test_amax(dtype):
13+
def test_amax_amin(func, keepdims, dtype):
1214
a = numpy.array(
1315
[
1416
[[-2.0, 3.0], [9.1, 0.2]],
@@ -20,26 +22,8 @@ def test_amax(dtype):
2022
ia = dpnp.array(a)
2123

2224
for axis in range(len(a)):
23-
result = dpnp.amax(ia, axis=axis)
24-
expected = numpy.amax(a, axis=axis)
25-
assert_allclose(expected, result)
26-
27-
28-
@pytest.mark.parametrize("dtype", get_all_dtypes())
29-
def test_amin(dtype):
30-
a = numpy.array(
31-
[
32-
[[-2.0, 3.0], [9.1, 0.2]],
33-
[[-2.0, 5.0], [-2, -1.2]],
34-
[[1.0, -2.0], [5.0, -1.1]],
35-
],
36-
dtype=dtype,
37-
)
38-
ia = dpnp.array(a)
39-
40-
for axis in range(len(a)):
41-
result = dpnp.amin(ia, axis=axis)
42-
expected = numpy.amin(a, axis=axis)
25+
result = getattr(dpnp, func)(ia, axis=axis, keepdims=keepdims)
26+
expected = getattr(numpy, func)(a, axis=axis, keepdims=keepdims)
4327
assert_allclose(expected, result)
4428

4529

0 commit comments

Comments
 (0)