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

Skip to content

Commit 40dce9c

Browse files
committed
Change handling of masked arrays.
Instead of changing masked values to NaNs, change NaNs to masked values.
1 parent 7d01052 commit 40dce9c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/matplotlib/streamplot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
7979
assert u.shape == grid.shape
8080
assert v.shape == grid.shape
8181

82-
if np.ma.is_masked(u):
83-
u = u.astype(float).filled(np.nan)
84-
if np.ma.is_masked(v):
85-
v = v.astype(float).filled(np.nan)
82+
if np.any(np.isnan(u)):
83+
u = np.ma.array(u, mask=np.isnan(u))
84+
if np.any(np.isnan(v)):
85+
v = np.ma.array(v, mask=np.isnan(v))
8686

8787
integrate = get_integrator(u, v, dmap, minlength)
8888

@@ -505,7 +505,7 @@ def interpgrid(a, xi, yi):
505505
ai = a0 * (1 - yt) + a1 * yt
506506

507507
if not type(xi) == np.ndarray:
508-
if np.isnan(ai):
508+
if np.ma.is_masked(ai):
509509
raise TerminateTrajectory
510510

511511
return ai

0 commit comments

Comments
 (0)