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

Skip to content

Commit d02ed8c

Browse files
committed
Make quiver handle nans and infs
svn path=/trunk/matplotlib/; revision=7104
1 parent 3ccf30d commit d02ed8c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/matplotlib/quiver.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ def _parse_args(self, *args):
388388
X, Y, U, V, C = [None]*5
389389
args = list(args)
390390
if len(args) == 3 or len(args) == 5:
391-
C = ma.asarray(args.pop(-1))
392-
V = ma.asarray(args.pop(-1))
393-
U = ma.asarray(args.pop(-1))
391+
C = ma.masked_invalid(args.pop(-1), copy=False)
392+
V = ma.masked_invalid(args.pop(-1), copy=False)
393+
U = ma.masked_invalid(args.pop(-1), copy=False)
394394
if U.ndim == 1:
395395
nr, nc = 1, U.shape[0]
396396
else:
@@ -483,7 +483,8 @@ def _make_verts(self, U, V):
483483
elif self.angles == 'uv':
484484
theta = np.angle(uv.filled(0))
485485
else:
486-
theta = ma.asarray(self.angles).filled(0)*np.pi/180.0
486+
theta = ma.masked_invalid(self.angles, copy=False).filled(0)
487+
theta *= (np.pi/180.0)
487488
theta.shape = (theta.shape[0], 1) # for broadcasting
488489
xy = (X+Y*1j) * np.exp(1j*theta)*self.width
489490
xy = xy[:,:,np.newaxis]
@@ -919,9 +920,9 @@ def _parse_args(self, *args):
919920
X, Y, U, V, C = [None]*5
920921
args = list(args)
921922
if len(args) == 3 or len(args) == 5:
922-
C = ma.asarray(args.pop(-1)).ravel()
923-
V = ma.asarray(args.pop(-1))
924-
U = ma.asarray(args.pop(-1))
923+
C = ma.masked_invalid(args.pop(-1), copy=False).ravel()
924+
V = ma.masked_invalid(args.pop(-1), copy=False)
925+
U = ma.masked_invalid(args.pop(-1), copy=False)
925926
nn = np.shape(U)
926927
nc = nn[0]
927928
nr = 1
@@ -937,10 +938,10 @@ def _parse_args(self, *args):
937938
return X, Y, U, V, C
938939

939940
def set_UVC(self, U, V, C=None):
940-
self.u = ma.asarray(U).ravel()
941-
self.v = ma.asarray(V).ravel()
941+
self.u = ma.masked_invalid(U, copy=False).ravel()
942+
self.v = ma.masked_invalid(V, copy=False).ravel()
942943
if C is not None:
943-
c = ma.asarray(C).ravel()
944+
c = ma.masked_invalid(C, copy=False).ravel()
944945
x,y,u,v,c = delete_masked_points(self.x.ravel(), self.y.ravel(),
945946
self.u, self.v, c)
946947
else:

0 commit comments

Comments
 (0)