summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.py
diff options
context:
space:
mode:
authorBrigitta Sipőcz <bsipocz@gmail.com>2022-07-17 05:58:53 -0700
committerGitHub <noreply@github.com>2022-07-17 15:58:53 +0300
commit6b8d55e66e532d66e1701ad039b4cda306839b3f (patch)
tree9f446600db7874e9c4d8f70193d62fc1220bd790 /numpy/ma/extras.py
parent7a93aa6b55af024d8116ea4ffd376eac15b9db59 (diff)
downloadnumpy-6b8d55e66e532d66e1701ad039b4cda306839b3f.tar.gz
BUG: Fix masked median multiple masked arrays (#21999)
Fixed issue that occurs when trying to take the median of a list of masked arrays. Added a check to see if the input is a list then converts to a masked array. See issue #10757 for more information. Co-authored-by: jsclose <jsclose@umich.edu>
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r--numpy/ma/extras.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index b3016da5a..911135505 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -723,7 +723,10 @@ def median(a, axis=None, out=None, overwrite_input=False, keepdims=False):
fill_value=1e+20)
"""
- if not hasattr(a, 'mask'):
+
+ a = np.ma.asarray(a)
+
+ if a.mask is np.ma.nomask:
m = np.median(getdata(a, subok=True), axis=axis,
out=out, overwrite_input=overwrite_input,
keepdims=keepdims)