@@ -6055,7 +6055,7 @@ def _normalize_input(inp, ename='input'):
6055
6055
if (isinstance (x , np .ndarray ) or
6056
6056
not iterable (cbook .safe_first_element (inp ))):
6057
6057
6058
- inp = np . asarray (inp )
6058
+ inp = cbook . safe_masked_invalid (inp )
6059
6059
if inp .ndim == 2 :
6060
6060
# 2-D input with columns as datasets; switch to rows
6061
6061
inp = inp .T
@@ -6077,7 +6077,7 @@ def _normalize_input(inp, ename='input'):
6077
6077
"{ename} must be 1D or 2D" .format (ename = ename ))
6078
6078
else :
6079
6079
# Change to a list of arrays
6080
- inp = [np . asarray (arr ) for arr in inp ]
6080
+ inp = [cbook . safe_masked_invalid (arr ) for arr in inp ]
6081
6081
6082
6082
return inp
6083
6083
@@ -6138,24 +6138,25 @@ def _normalize_input(inp, ename='input'):
6138
6138
else :
6139
6139
w = _normalize_input (weights , 'weights' )
6140
6140
6141
+ # Comparing shape of weights vs. x
6141
6142
if len (w ) != nx :
6142
6143
raise ValueError ('weights should have the same shape as x' )
6143
6144
6144
- # Masking invalid data:
6145
- # Where an element of x[i] is invalid (NaN or inf), it and the
6146
- # corresponding element of weights[i] (if weights used) will be masked.
6147
- for i in range (len (x )):
6148
- xi_mask = np .ma .masked_invalid (x [i ]).mask
6149
- x [i ] = np .ma .masked_array (x [i ], mask = xi_mask ).compressed ()
6150
- if weights [i ]:
6151
- weights [i ] = np .ma .masked_array (
6152
- weights [i ], mask = xi_mask ).compressed ()
6153
-
6154
6145
for xi , wi in zip (x , w ):
6155
6146
if wi is not None and len (wi ) != len (xi ):
6156
6147
raise ValueError (
6157
6148
'weights should have the same shape as x' )
6158
6149
6150
+ # Combine the masks from x[i] and w[i] (if applicable) into a single
6151
+ # mask and apply it to both.
6152
+ if not input_empty :
6153
+ for i in range (len (x )):
6154
+ mask_i = x [i ].mask
6155
+ if w [i ] is not None :
6156
+ mask_i = mask_i | w [i ].mask
6157
+ w [i ] = np .ma .masked_array (w [i ], mask = mask_i ).compressed ()
6158
+ x [i ] = np .ma .masked_array (x [i ], mask = mask_i ).compressed ()
6159
+
6159
6160
if color is None :
6160
6161
color = [self ._get_lines .get_next_color () for i in xrange (nx )]
6161
6162
else :
0 commit comments