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

Skip to content

Commit 63fe909

Browse files
authored
Merge pull request #12796 from anntzer/quiver3d
Simplifications to quiver3d.
2 parents 8799411 + c4ad02b commit 63fe909

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,15 +2636,12 @@ def calc_arrow(uvw, angle=15):
26362636

26372637
# first 6 arguments are X, Y, Z, U, V, W
26382638
input_args = args[:argi]
2639-
# if any of the args are scalar, convert into list
2640-
input_args = [[k] if isinstance(k, (int, float)) else k
2641-
for k in input_args]
26422639

26432640
# extract the masks, if any
26442641
masks = [k.mask for k in input_args
26452642
if isinstance(k, np.ma.MaskedArray)]
26462643
# broadcast to match the shape
2647-
bcast = np.broadcast_arrays(*(input_args + masks))
2644+
bcast = np.broadcast_arrays(*input_args, *masks)
26482645
input_args = bcast[:argi]
26492646
masks = bcast[argi:]
26502647
if masks:
@@ -2654,21 +2651,15 @@ def calc_arrow(uvw, angle=15):
26542651
input_args = [np.ma.array(k, mask=mask).compressed()
26552652
for k in input_args]
26562653
else:
2657-
input_args = [k.flatten() for k in input_args]
2654+
input_args = [np.ravel(k) for k in input_args]
26582655

26592656
if any(len(v) == 0 for v in input_args):
26602657
# No quivers, so just make an empty collection and return early
26612658
linec = art3d.Line3DCollection([], *args[argi:], **kwargs)
26622659
self.add_collection(linec)
26632660
return linec
26642661

2665-
# Following assertions must be true before proceeding
2666-
# must all be ndarray
2667-
assert all(isinstance(k, np.ndarray) for k in input_args)
2668-
# must all in same shape
2669-
assert len({k.shape for k in input_args}) == 1
2670-
2671-
shaft_dt = np.linspace(0, length, num=2)
2662+
shaft_dt = np.array([0, length])
26722663
arrow_dt = shaft_dt * arrow_length_ratio
26732664

26742665
if pivot == 'tail':

0 commit comments

Comments
 (0)