@@ -392,6 +392,12 @@ def _parse_args(*args):
392
392
return X , Y , U , V , C
393
393
394
394
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
+
395
401
class Quiver (mcollections .PolyCollection ):
396
402
"""
397
403
Specialized PolyCollection for arrows.
@@ -1124,9 +1130,11 @@ def set_UVC(self, U, V, C=None):
1124
1130
x , y , u , v , c = delete_masked_points (self .x .ravel (),
1125
1131
self .y .ravel (),
1126
1132
self .u , self .v , c )
1133
+ _check_consistent_shapes (x , y , u , v , c )
1127
1134
else :
1128
1135
x , y , u , v = delete_masked_points (self .x .ravel (), self .y .ravel (),
1129
1136
self .u , self .v )
1137
+ _check_consistent_shapes (x , y , u , v )
1130
1138
1131
1139
magnitude = np .hypot (u , v )
1132
1140
flags , barbs , halves , empty = self ._find_tails (magnitude ,
@@ -1151,16 +1159,17 @@ def set_UVC(self, U, V, C=None):
1151
1159
1152
1160
def set_offsets (self , xy ):
1153
1161
"""
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.
1157
1165
1158
1166
ACCEPTS: sequence of pairs of floats
1159
1167
"""
1160
1168
self .x = xy [:, 0 ]
1161
1169
self .y = xy [:, 1 ]
1162
1170
x , y , u , v = delete_masked_points (self .x .ravel (), self .y .ravel (),
1163
1171
self .u , self .v )
1172
+ _check_consistent_shapes (x , y , u , v )
1164
1173
xy = np .hstack ((x [:, np .newaxis ], y [:, np .newaxis ]))
1165
1174
mcollections .PolyCollection .set_offsets (self , xy )
1166
1175
self .stale = True
0 commit comments