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

Skip to content

Commit eea3d1a

Browse files
committed
MNT: do minimal input validation in Axes3D.set_box_aspect
1 parent 4c0b944 commit eea3d1a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,13 @@ def set_box_aspect(self, aspect, *, zoom=1):
385385
if aspect is None:
386386
aspect = np.asarray((4, 4, 3), dtype=float)
387387
else:
388+
orig_aspect = aspect
388389
aspect = np.asarray(aspect, dtype=float)
390+
if aspect.shape != (3,):
391+
raise ValueError(
392+
"You must pass a 3-tuple that can be cast to floats. "
393+
f"You passed {orig_aspect!r}"
394+
)
389395
# default scale tuned to match the mpl32 appearance.
390396
aspect *= 1.8294640721620434 * zoom / np.linalg.norm(aspect)
391397

0 commit comments

Comments
 (0)