@@ -56,12 +56,12 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
5656
5757 if color is None :
5858 color = matplotlib .rcParams ['lines.color' ]
59- elif type (color ) == np .ndarray :
59+ elif isinstance (color , np .ndarray ) :
6060 assert color .shape == grid .shape
6161
6262 if linewidth is None :
6363 linewidth = matplotlib .rcParams ['lines.linewidth' ]
64- elif type (linewidth ) == np .ndarray :
64+ elif isinstance (linewidth , np .ndarray ) :
6565 assert linewidth .shape == grid .shape
6666
6767 ## Sanity checks.
@@ -84,21 +84,21 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
8484 trajectories .append (t )
8585
8686 # Load up the defaults - needed to get the color right.
87- if type (color ) == np .ndarray :
87+ if isinstance (color , np .ndarray ) :
8888 norm = matplotlib .colors .normalize (color .min (), color .max ())
8989 if cmap == None : cmap = matplotlib .cm .get_cmap (
9090 matplotlib .rcParams ['image.cmap' ])
9191
9292 line_kw = {}
9393 arrow_kw = dict (arrowstyle = arrowstyle , mutation_scale = 10 * arrowsize )
9494
95- if type (linewidth ) == np .ndarray :
95+ if isinstance (linewidth , np .ndarray ) :
9696 line_kw ['linewidth' ] = []
9797 else :
9898 line_kw ['linewidth' ] = linewidth
9999 arrow_kw ['linewidth' ] = linewidth
100100
101- if type (color ) == np .ndarray :
101+ if isinstance (color , np .ndarray ) :
102102 line_colors = []
103103 else :
104104 line_kw ['color' ] = color
@@ -121,12 +121,12 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
121121 arrow_tail = (tx [n ], ty [n ])
122122 arrow_head = (np .mean (tx [n :n + 2 ]), np .mean (ty [n :n + 2 ]))
123123
124- if type (linewidth ) == np .ndarray :
124+ if isinstance (linewidth , np .ndarray ) :
125125 line_widths = interpgrid (linewidth , tgx , tgy )[:- 1 ]
126126 line_kw ['linewidth' ].extend (line_widths )
127127 arrow_kw ['linewidth' ] = line_widths [n ]
128128
129- if type (color ) == np .ndarray :
129+ if isinstance (color , np .ndarray ) :
130130 color_values = interpgrid (color , tgx , tgy )[:- 1 ]
131131 line_colors .extend (color_values )
132132 arrow_kw ['color' ] = cmap (norm (color_values [n ]))
@@ -135,7 +135,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
135135 axes .add_patch (p )
136136
137137 lc = matplotlib .collections .LineCollection (streamlines , ** line_kw )
138- if type (color ) == np .ndarray :
138+ if isinstance (color , np .ndarray ) :
139139 lc .set_array (np .asarray (line_colors ))
140140 lc .set_cmap (cmap )
141141 lc .set_norm (norm )
@@ -472,7 +472,7 @@ def interpgrid(a, xi, yi):
472472 """Fast 2D, linear interpolation on an integer grid"""
473473
474474 Ny , Nx = np .shape (a )
475- if type (xi ) == np .ndarray :
475+ if isinstance (xi , np .ndarray ) :
476476 x = xi .astype (np .int )
477477 y = yi .astype (np .int )
478478 # Check that xn, yn don't exceed max index
@@ -497,7 +497,7 @@ def interpgrid(a, xi, yi):
497497 a1 = a10 * (1 - xt ) + a11 * xt
498498 ai = a0 * (1 - yt ) + a1 * yt
499499
500- if not type (xi ) == np .ndarray :
500+ if not isinstance (xi , np .ndarray ) :
501501 if np .ma .is_masked (ai ):
502502 raise TerminateTrajectory
503503
0 commit comments