Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Remove long deprecated functionality from np.ma #22228

Merged
merged 3 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/release/upcoming_changes/22228.expired.rst
@@ -0,0 +1,6 @@
The mini() method of np.ma.MaskedArray has been removed. Use either
np.ma.MaskedArray.min() or np.ma.minimum.reduce().


The single-argument form of np.ma.minimum and np.ma.maximum has been
removed. Use np.ma.minimum.reduce() or np.ma.maximum.reduce() instead.
bsipocz marked this conversation as resolved.
Show resolved Hide resolved
84 changes: 2 additions & 82 deletions numpy/ma/core.py
Expand Up @@ -5804,74 +5804,6 @@ def min(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue):
np.copyto(out, np.nan, where=newmask)
return out

# unique to masked arrays
def mini(self, axis=None):
"""
Return the array minimum along the specified axis.

.. deprecated:: 1.13.0
This function is identical to both:

* ``self.min(keepdims=True, axis=axis).squeeze(axis=axis)``
* ``np.ma.minimum.reduce(self, axis=axis)``

Typically though, ``self.min(axis=axis)`` is sufficient.

Parameters
----------
axis : int, optional
The axis along which to find the minima. Default is None, in which case
the minimum value in the whole array is returned.

Returns
-------
min : scalar or MaskedArray
If `axis` is None, the result is a scalar. Otherwise, if `axis` is
given and the array is at least 2-D, the result is a masked array with
dimension one smaller than the array on which `mini` is called.

Examples
--------
>>> x = np.ma.array(np.arange(6), mask=[0 ,1, 0, 0, 0 ,1]).reshape(3, 2)
>>> x
masked_array(
data=[[0, --],
[2, 3],
[4, --]],
mask=[[False, True],
[False, False],
[False, True]],
fill_value=999999)
>>> x.mini()
masked_array(data=0,
mask=False,
fill_value=999999)
>>> x.mini(axis=0)
masked_array(data=[0, 3],
mask=[False, False],
fill_value=999999)
>>> x.mini(axis=1)
masked_array(data=[0, 2, 4],
mask=[False, False, False],
fill_value=999999)

There is a small difference between `mini` and `min`:

>>> x[:,1].mini(axis=0)
masked_array(data=3,
mask=False,
fill_value=999999)
>>> x[:,1].min(axis=0)
3
"""

# 2016-04-13, 1.13.0, gh-8764
warnings.warn(
"`mini` is deprecated; use the `min` method or "
"`np.ma.minimum.reduce instead.",
DeprecationWarning, stacklevel=2)
return minimum.reduce(self, axis)

def max(self, axis=None, out=None, fill_value=None, keepdims=np._NoValue):
"""
Return the maximum along a given axis.
Expand Down Expand Up @@ -6719,15 +6651,9 @@ def __init__(self, ufunc, compare, fill_value):
self.compare = compare
self.fill_value_func = fill_value

def __call__(self, a, b=None):
def __call__(self, a, b):
"Executes the call behavior."
if b is None:
# 2016-04-13, 1.13.0
warnings.warn(
f"Single-argument form of np.ma.{self.__name__} is deprecated. Use "
f"np.ma.{self.__name__}.reduce instead.",
DeprecationWarning, stacklevel=2)
return self.reduce(a)

return where(self.compare(a, b), a, b)

def reduce(self, target, axis=np._NoValue):
Expand Down Expand Up @@ -8090,12 +8016,6 @@ def asanyarray(a, dtype=None):
# Pickling #
##############################################################################

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


def fromfile(file, dtype=float, count=-1, sep=''):
raise NotImplementedError(
Expand Down
5 changes: 0 additions & 5 deletions numpy/ma/tests/test_deprecations.py
Expand Up @@ -39,11 +39,6 @@ def test_method(self):


class TestMinimumMaximum:
def test_minimum(self):
assert_warns(DeprecationWarning, np.ma.minimum, np.ma.array([1, 2]))

def test_maximum(self):
assert_warns(DeprecationWarning, np.ma.maximum, np.ma.array([1, 2]))

def test_axis_default(self):
# NumPy 1.13, 2017-05-06
Expand Down