Skip to content

Commit 187f5da

Browse files
author
Vedant Nanda
committed
parametrized tests and cleaner calls to validate
1 parent 0753a56 commit 187f5da

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,15 @@ def _determine_lims(self, xmin=None, xmax=None, *args, **kwargs):
589589

590590
def _validate_axis_limits(self, limit, convert):
591591
"""
592-
If the axis limits being set are infinite, this function
593-
594-
raises an error.
592+
Raise ValueError if specified axis limits are infinite.
595593
596594
"""
597595
if limit is not None:
596+
converted_limits = convert(limit)
598597
if (isinstance(limit, float) and
599598
(not np.isreal(limit) or not np.isfinite(limit))):
600-
raise ValueError("NaN or Inf cannot be the argument values")
601-
return convert(limit)
599+
raise ValueError("Axis limits cannot be NaN or Inf")
600+
return converted_limits
602601

603602
def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
604603
"""

lib/mpl_toolkits/tests/test_mplot3d.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def test_axes3d_ortho():
560560
])
561561
def test_invalid_axes_limits(setter, side, value):
562562
limit = {side: value}
563+
fig = plt.figure()
564+
obj = fig.add_subplot(111, projection='3d')
563565
with pytest.raises(ValueError):
564-
fig = plt.figure()
565-
obj = fig.add_subplot(111, projection='3d')
566566
getattr(obj, setter)(**limit)

0 commit comments

Comments
 (0)