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

Skip to content

Simplifications to quiver3d. #12796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2637,15 +2637,12 @@ def calc_arrow(uvw, angle=15):

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

# extract the masks, if any
masks = [k.mask for k in input_args
if isinstance(k, np.ma.MaskedArray)]
# broadcast to match the shape
bcast = np.broadcast_arrays(*(input_args + masks))
bcast = np.broadcast_arrays(*input_args, *masks)
input_args = bcast[:argi]
masks = bcast[argi:]
if masks:
Expand All @@ -2655,21 +2652,15 @@ def calc_arrow(uvw, angle=15):
input_args = [np.ma.array(k, mask=mask).compressed()
for k in input_args]
else:
input_args = [k.flatten() for k in input_args]
input_args = [np.ravel(k) for k in input_args]

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

# Following assertions must be true before proceeding
# must all be ndarray
assert all(isinstance(k, np.ndarray) for k in input_args)
# must all in same shape
assert len({k.shape for k in input_args}) == 1

shaft_dt = np.linspace(0, length, num=2)
shaft_dt = np.array([0, length])
arrow_dt = shaft_dt * arrow_length_ratio

if pivot == 'tail':
Expand Down