Skip to content

Commit 397b6e5

Browse files
authored
Merge pull request numpy#22228 from bsipocz/ma_cleanup_old_deprecations
MAINT: Remove long deprecated functionality from np.ma
2 parents b63d475 + cf94f4f commit 397b6e5

File tree

3 files changed

+7
-87
lines changed

3 files changed

+7
-87
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* The mini() method of ``np.ma.MaskedArray`` has been removed. Use either
2+
``np.ma.MaskedArray.min()`` or ``np.ma.minimum.reduce()``.
3+
4+
* The single-argument form of ``np.ma.minimum`` and ``np.ma.maximum`` has been
5+
removed. Use ``np.ma.minimum.reduce()`` or ``np.ma.maximum.reduce()`` instead.

numpy/ma/core.py

+2-82
Original file line numberDiff line numberDiff line change
@@ -5804,74 +5804,6 @@ def min(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue):
58045804
np.copyto(out, np.nan, where=newmask)
58055805
return out
58065806

5807-
# unique to masked arrays
5808-
def mini(self, axis=None):
5809-
"""
5810-
Return the array minimum along the specified axis.
5811-
5812-
.. deprecated:: 1.13.0
5813-
This function is identical to both:
5814-
5815-
* ``self.min(keepdims=True, axis=axis).squeeze(axis=axis)``
5816-
* ``np.ma.minimum.reduce(self, axis=axis)``
5817-
5818-
Typically though, ``self.min(axis=axis)`` is sufficient.
5819-
5820-
Parameters
5821-
----------
5822-
axis : int, optional
5823-
The axis along which to find the minima. Default is None, in which case
5824-
the minimum value in the whole array is returned.
5825-
5826-
Returns
5827-
-------
5828-
min : scalar or MaskedArray
5829-
If `axis` is None, the result is a scalar. Otherwise, if `axis` is
5830-
given and the array is at least 2-D, the result is a masked array with
5831-
dimension one smaller than the array on which `mini` is called.
5832-
5833-
Examples
5834-
--------
5835-
>>> x = np.ma.array(np.arange(6), mask=[0 ,1, 0, 0, 0 ,1]).reshape(3, 2)
5836-
>>> x
5837-
masked_array(
5838-
data=[[0, --],
5839-
[2, 3],
5840-
[4, --]],
5841-
mask=[[False, True],
5842-
[False, False],
5843-
[False, True]],
5844-
fill_value=999999)
5845-
>>> x.mini()
5846-
masked_array(data=0,
5847-
mask=False,
5848-
fill_value=999999)
5849-
>>> x.mini(axis=0)
5850-
masked_array(data=[0, 3],
5851-
mask=[False, False],
5852-
fill_value=999999)
5853-
>>> x.mini(axis=1)
5854-
masked_array(data=[0, 2, 4],
5855-
mask=[False, False, False],
5856-
fill_value=999999)
5857-
5858-
There is a small difference between `mini` and `min`:
5859-
5860-
>>> x[:,1].mini(axis=0)
5861-
masked_array(data=3,
5862-
mask=False,
5863-
fill_value=999999)
5864-
>>> x[:,1].min(axis=0)
5865-
3
5866-
"""
5867-
5868-
# 2016-04-13, 1.13.0, gh-8764
5869-
warnings.warn(
5870-
"`mini` is deprecated; use the `min` method or "
5871-
"`np.ma.minimum.reduce instead.",
5872-
DeprecationWarning, stacklevel=2)
5873-
return minimum.reduce(self, axis)
5874-
58755807
def max(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue):
58765808
"""
58775809
Return the maximum along a given axis.
@@ -6719,15 +6651,9 @@ def __init__(self, ufunc, compare, fill_value):
67196651
self.compare = compare
67206652
self.fill_value_func = fill_value
67216653

6722-
def __call__(self, a, b=None):
6654+
def __call__(self, a, b):
67236655
"Executes the call behavior."
6724-
if b is None:
6725-
# 2016-04-13, 1.13.0
6726-
warnings.warn(
6727-
f"Single-argument form of np.ma.{self.__name__} is deprecated. Use "
6728-
f"np.ma.{self.__name__}.reduce instead.",
6729-
DeprecationWarning, stacklevel=2)
6730-
return self.reduce(a)
6656+
67316657
return where(self.compare(a, b), a, b)
67326658

67336659
def reduce(self, target, axis=np._NoValue):
@@ -8090,12 +8016,6 @@ def asanyarray(a, dtype=None):
80908016
# Pickling #
80918017
##############################################################################
80928018

8093-
def _pickle_warn(method):
8094-
# NumPy 1.15.0, 2017-12-10
8095-
warnings.warn(
8096-
f"np.ma.{method} is deprecated, use pickle.{method} instead",
8097-
DeprecationWarning, stacklevel=3)
8098-
80998019

81008020
def fromfile(file, dtype=float, count=-1, sep=''):
81018021
raise NotImplementedError(

numpy/ma/tests/test_deprecations.py

-5
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ def test_method(self):
3939

4040

4141
class TestMinimumMaximum:
42-
def test_minimum(self):
43-
assert_warns(DeprecationWarning, np.ma.minimum, np.ma.array([1, 2]))
44-
45-
def test_maximum(self):
46-
assert_warns(DeprecationWarning, np.ma.maximum, np.ma.array([1, 2]))
4742

4843
def test_axis_default(self):
4944
# NumPy 1.13, 2017-05-06

0 commit comments

Comments
 (0)