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

Skip to content

Commit 939a670

Browse files
committed
Merge remote-tracking branch 'upstream/v2.x' into merge_from_v2.x
Conflicts: lib/matplotlib/tests/test_axes.py lib/matplotlib/tests/test_quiver.py Resolved by adding new tests from v2.x.
2 parents 6709b59 + cb21ba7 commit 939a670

29 files changed

Lines changed: 44 additions & 4 deletions

lib/matplotlib/quiver.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ def _parse_args(*args):
392392
return X, Y, U, V, C
393393

394394

395+
def _check_consistent_shapes(*arrays):
396+
all_shapes = set(a.shape for a in arrays)
397+
if len(all_shapes) != 1:
398+
raise ValueError('The shapes of the passed in arrays do not match.')
399+
400+
395401
class Quiver(mcollections.PolyCollection):
396402
"""
397403
Specialized PolyCollection for arrows.
@@ -1124,9 +1130,11 @@ def set_UVC(self, U, V, C=None):
11241130
x, y, u, v, c = delete_masked_points(self.x.ravel(),
11251131
self.y.ravel(),
11261132
self.u, self.v, c)
1133+
_check_consistent_shapes(x, y, u, v, c)
11271134
else:
11281135
x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(),
11291136
self.u, self.v)
1137+
_check_consistent_shapes(x, y, u, v)
11301138

11311139
magnitude = np.hypot(u, v)
11321140
flags, barbs, halves, empty = self._find_tails(magnitude,
@@ -1151,16 +1159,17 @@ def set_UVC(self, U, V, C=None):
11511159

11521160
def set_offsets(self, xy):
11531161
"""
1154-
Set the offsets for the barb polygons. This saves the offets passed in
1155-
and actually sets version masked as appropriate for the existing U/V
1156-
data. *offsets* should be a sequence.
1162+
Set the offsets for the barb polygons. This saves the offsets passed
1163+
in and actually sets version masked as appropriate for the existing
1164+
U/V data. *offsets* should be a sequence.
11571165
11581166
ACCEPTS: sequence of pairs of floats
11591167
"""
11601168
self.x = xy[:, 0]
11611169
self.y = xy[:, 1]
11621170
x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(),
11631171
self.u, self.v)
1172+
_check_consistent_shapes(x, y, u, v)
11641173
xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis]))
11651174
mcollections.PolyCollection.set_offsets(self, xy)
11661175
self.stale = True
-576 Bytes
Loading
15 Bytes
Loading
-55 Bytes
Loading
-167 Bytes
Loading
-71 Bytes
Loading
-63 Bytes
Loading
-66 Bytes
Loading
-33 Bytes
Loading
-53 Bytes
Loading

0 commit comments

Comments
 (0)