Skip to content
Snippets Groups Projects
Commit a15090b4 authored by Sandro Tosi's avatar Sandro Tosi
Browse files

Fix argument checking in Axes3D.quiver; Closes: #1027285

parent fc2674e6
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,10 @@ matplotlib (3.6.2-4) UNRELEASED; urgency=medium
* debian/rules
- run dh_installdocs on the -data pkg, to unstall changelog;
Closes: #1027049
* debian/patches/PR24862.patch
- Fix argument checking in Axes3D.quiver; Closes: #1027285
-- Sandro Tosi <morph@debian.org> Thu, 05 Jan 2023 10:59:33 -0500
-- Sandro Tosi <morph@debian.org> Thu, 05 Jan 2023 23:48:31 -0500
matplotlib (3.6.2-3) unstable; urgency=medium
......
From 8f0792cb9c8d80ff17d1f8f0500897f0e56e8fea Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Sun, 1 Jan 2023 14:55:41 +0100
Subject: [PATCH] Fix argument checking in Axes3D.quiver
---
lib/mpl_toolkits/mplot3d/axes3d.py | 45 ++++++++++++------------------
1 file changed, 18 insertions(+), 27 deletions(-)
--- a/lib/mpl_toolkits/mplot3d/axes3d.py
+++ b/lib/mpl_toolkits/mplot3d/axes3d.py
@@ -1372,7 +1372,7 @@ class Axes3D(Axes):
The lightsource to use when *shade* is True.
**kwargs
- Other arguments are forwarded to `.Poly3DCollection`.
+ Other keyword arguments are forwarded to `.Poly3DCollection`.
"""
had_data = self.has_data()
@@ -1620,7 +1620,7 @@ class Axes3D(Axes):
of the new default of ``rcount = ccount = 50``.
**kwargs
- Other arguments are forwarded to `.Line3DCollection`.
+ Other keyword arguments are forwarded to `.Line3DCollection`.
"""
had_data = self.has_data()
@@ -1747,7 +1747,7 @@ class Axes3D(Axes):
lightsource : `~matplotlib.colors.LightSource`
The lightsource to use when *shade* is True.
**kwargs
- All other arguments are passed on to
+ All other keyword arguments are passed on to
:class:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
Examples
@@ -2156,7 +2156,7 @@ class Axes3D(Axes):
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
- All other arguments are passed on to `~.axes.Axes.scatter`.
+ All other keyword arguments are passed on to `~.axes.Axes.scatter`.
Returns
-------
@@ -2208,7 +2208,8 @@ class Axes3D(Axes):
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
- Other arguments are forwarded to `matplotlib.axes.Axes.bar`.
+ Other keyword arguments are forwarded to
+ `matplotlib.axes.Axes.bar`.
Returns
-------
@@ -2417,19 +2418,16 @@ class Axes3D(Axes):
return ret
@_preprocess_data()
- def quiver(self, *args,
+ def quiver(self, X, Y, Z, U, V, W, *,
length=1, arrow_length_ratio=.3, pivot='tail', normalize=False,
**kwargs):
"""
- ax.quiver(X, Y, Z, U, V, W, /, length=1, arrow_length_ratio=.3, \
-pivot='tail', normalize=False, **kwargs)
-
Plot a 3D field of arrows.
- The arguments could be array-like or scalars, so long as they
- they can be broadcast together. The arguments can also be
- masked arrays. If an element in any of argument is masked, then
- that corresponding quiver element will not be plotted.
+ The arguments can be array-like or scalars, so long as they can be
+ broadcast together. The arguments can also be masked arrays. If an
+ element in any of argument is masked, then that corresponding quiver
+ element will not be plotted.
Parameters
----------
@@ -2459,7 +2457,7 @@ pivot='tail', normalize=False, **kwargs)
**kwargs
Any additional keyword arguments are delegated to
- :class:`~matplotlib.collections.LineCollection`
+ :class:`.Line3DCollection`
"""
def calc_arrows(UVW, angle=15):
@@ -2490,22 +2488,15 @@ pivot='tail', normalize=False, **kwargs)
had_data = self.has_data()
- # handle args
- argi = 6
- if len(args) < argi:
- raise ValueError('Wrong number of arguments. Expected %d got %d' %
- (argi, len(args)))
-
- # first 6 arguments are X, Y, Z, U, V, W
- input_args = args[:argi]
+ input_args = [X, Y, Z, U, V, W]
# 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)
- input_args = bcast[:argi]
- masks = bcast[argi:]
+ input_args = bcast[:6]
+ masks = bcast[6:]
if masks:
# combine the masks into one
mask = functools.reduce(np.logical_or, masks)
@@ -2517,7 +2508,7 @@ pivot='tail', normalize=False, **kwargs)
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)
+ linec = art3d.Line3DCollection([], **kwargs)
self.add_collection(linec)
return linec
@@ -2531,7 +2522,7 @@ pivot='tail', normalize=False, **kwargs)
shaft_dt -= length / 2
XYZ = np.column_stack(input_args[:3])
- UVW = np.column_stack(input_args[3:argi]).astype(float)
+ UVW = np.column_stack(input_args[3:]).astype(float)
# Normalize rows of UVW
norm = np.linalg.norm(UVW, axis=1)
@@ -2560,7 +2551,7 @@ pivot='tail', normalize=False, **kwargs)
else:
lines = []
- linec = art3d.Line3DCollection(lines, *args[argi:], **kwargs)
+ linec = art3d.Line3DCollection(lines, **kwargs)
self.add_collection(linec)
self.auto_scale_xyz(XYZ[:, 0], XYZ[:, 1], XYZ[:, 2], had_data)
......@@ -6,3 +6,4 @@
#0013-static-SHA.patch
0014-py3k-sphinx.patch
0015-disable-sphinx--W.patch
PR24862.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment