@@ -1102,8 +1102,10 @@ def _combine_masks(*args):
11021102 Masks are obtained from all arguments of the correct length
11031103 in categories 1, 2, and 4; a point is bad if masked in a masked
11041104 array or if it is a nan or inf. No attempt is made to
1105- extract a mask from categories 2, 3, and 4 if :meth:`np.isfinite`
1106- does not yield a Boolean array.
1105+ extract a mask from categories 2 and 4 if :meth:`np.isfinite`
1106+ does not yield a Boolean array. Category 3 is included to
1107+ support RGB or RGBA ndarrays, which are assumed to have only
1108+ valid values and which are passed through unchanged.
11071109
11081110 All input arguments that are not passed unchanged are returned
11091111 as masked arrays if any masked points are found, otherwise as
@@ -1117,6 +1119,7 @@ def _combine_masks(*args):
11171119 nrecs = len (args [0 ])
11181120 margs = []
11191121 seqlist = [False ] * len (args )
1122+ masks = [] # list of masks that are True where bad
11201123 for i , x in enumerate (args ):
11211124 if not isinstance (x , str ) and np .iterable (x ) and len (x ) == nrecs :
11221125 if isinstance (x , np .ma .MaskedArray ):
@@ -1126,21 +1129,14 @@ def _combine_masks(*args):
11261129 if x .ndim == 1 :
11271130 x = safe_masked_invalid (x )
11281131 seqlist [i ] = True
1132+ if np .ma .is_masked (x ):
1133+ masks .append (np .ma .getmaskarray (x ))
11291134 margs .append (x )
1130- masks = [] # list of masks that are True where bad
1131- for i , x in enumerate (margs ):
1132- if seqlist [i ]:
1133- if x .ndim > 1 :
1134- continue # Don't try to get nan locations unless 1-D.
1135- if np .ma .is_masked (x ):
1136- masks .append (np .ma .getmaskarray (x ))
11371135 if len (masks ):
11381136 mask = np .logical_or .reduce (masks )
1139- if mask .any ():
1140- for i , x in enumerate (margs ):
1141- if seqlist [i ]:
1142- margs [i ] = np .ma .array (x )
1143- margs [i ][mask ] = np .ma .masked
1137+ for i , x in enumerate (margs ):
1138+ if seqlist [i ]:
1139+ margs [i ] = np .ma .array (x , mask = mask )
11441140 return margs
11451141
11461142
0 commit comments