File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -368,11 +368,21 @@ def _set_transform(self):
368368
369369 def _make_verts (self , U , V ):
370370 uv = U + V * 1j
371- uv = nx .ravel (uv )
371+ uv = nx .ravel (nx . ma . filled ( uv , nx . nan ) )
372372 a = nx .absolute (uv )
373373 if self .scale is None :
374374 sn = max (10 , math .sqrt (self .N ))
375- scale = 1.8 * nx .average (a ) * sn # crude auto-scaling
375+
376+ # get valid values for average
377+ # (complicated by support for 3 array packages)
378+ a_valid_cond = ~ nx .isnan (a )
379+ a_valid_idx = nx .nonzero (a_valid_cond )
380+ if isinstance (a_valid_idx ,tuple ):
381+ # numpy.nonzero returns tuple
382+ a_valid_idx = a_valid_idx [0 ]
383+ valid_a = nx .take (a ,a_valid_idx )
384+
385+ scale = 1.8 * nx .average (valid_a ) * sn # crude auto-scaling
376386 scale = scale / self .span
377387 self .scale = scale
378388 length = a / (self .scale * self .width )
You can’t perform that action at this time.
0 commit comments