Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
BUG: fix ma.minimum.reduce with axis keyword
Fixes the problem reported at
#21977 (comment)

The reduce method here effectively calls itself with an unmasked
MaskedArray (mask=nomask) and then expects either a MaskedArray or
a scalar.  This change ensures that an ordinary ndarray is
converted to a MaskedArray, following the pattern already used in
mean and var in this module.
  • Loading branch information
rcomer committed Jul 16, 2022
commit b8c6d09208ecb7f0d83a8b06ab9e15e720f03730
2 changes: 2 additions & 0 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6875,6 +6875,8 @@ def reduce(self, target, axis=np._NoValue, **kwargs):

if m is nomask:
t = self.f.reduce(target.view(np.ndarray), **kwargs)
if isinstance(t, ndarray):
t = MaskedArray(t, mask=nomask)
else:
target = target.filled(
self.fill_value_func(target)).view(type(target))
Expand Down