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

Skip to content

Commit 40fc8f0

Browse files
Fix the rest of the tests
1 parent f567512 commit 40fc8f0

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,12 @@ def _set_bound3d(self, get_bound, set_lim, axis_inverted,
702702
def set_xbound(self, lower=None, upper=None, view_margin=None):
703703
# docstring inherited
704704
self._set_bound3d(self.get_xbound, self.set_xlim, self.xaxis_inverted,
705-
upper, lower, view_margin)
705+
lower, upper, view_margin)
706706

707707
def set_ybound(self, lower=None, upper=None, view_margin=None):
708708
# docstring inherited
709709
self._set_bound3d(self.get_ybound, self.set_ylim, self.yaxis_inverted,
710-
upper, lower, view_margin)
710+
lower, upper, view_margin)
711711

712712
def set_zbound(self, lower=None, upper=None, view_margin=None):
713713
"""
@@ -731,7 +731,7 @@ def set_zbound(self, lower=None, upper=None, view_margin=None):
731731
invert_zaxis, zaxis_inverted
732732
"""
733733
self._set_bound3d(self.get_zbound, self.set_zlim, self.zaxis_inverted,
734-
upper, lower, view_margin)
734+
lower, upper, view_margin)
735735

736736
def _set_lim3d(self, axis, lower=None, upper=None, *, emit=True,
737737
auto=False, view_margin=None, axmin=None, axmax=None):
@@ -742,10 +742,10 @@ def _set_lim3d(self, axis, lower=None, upper=None, *, emit=True,
742742
if upper is None:
743743
if np.iterable(lower):
744744
lower, upper = lower
745-
else:
746-
raise ValueError("Must provide an upper bound.")
747-
if lower is None:
748-
raise ValueError("Must provide a lower bound.")
745+
elif axmax is None:
746+
upper = axis.get_view_interval()[1]
747+
if lower is None and axmin is None:
748+
lower = axis.get_view_interval()[0]
749749
if axmin is not None:
750750
if lower is not None:
751751
raise TypeError("Cannot pass both 'lower' and 'min'")

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ def test_lines_dists_nowarning():
11961196
def test_autoscale():
11971197
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
11981198
assert ax.get_zscale() == 'linear'
1199+
ax._view_margin = 0
11991200
ax.margins(x=0, y=.1, z=.2)
12001201
ax.plot([0, 1], [0, 1], [0, 1])
12011202
assert ax.get_w_lims() == (0, 1, -.1, 1.1, -.2, 1.2)
@@ -1675,6 +1676,7 @@ def test_colorbar_pos():
16751676
def test_inverted_zaxis():
16761677
fig = plt.figure()
16771678
ax = fig.add_subplot(projection='3d')
1679+
ax.set_zlim(0, 1)
16781680
assert not ax.zaxis_inverted()
16791681
assert ax.get_zlim() == (0, 1)
16801682
assert ax.get_zbound() == (0, 1)
@@ -1707,17 +1709,17 @@ def test_inverted_zaxis():
17071709
def test_set_zlim():
17081710
fig = plt.figure()
17091711
ax = fig.add_subplot(projection='3d')
1710-
assert ax.get_zlim() == (0, 1)
1712+
assert np.allclose(ax.get_zlim(), (-1/48, 49/48))
17111713
ax.set_zlim(zmax=2)
1712-
assert ax.get_zlim() == (0, 2)
1714+
assert np.allclose(ax.get_zlim(), (-1/48, 2))
17131715
ax.set_zlim(zmin=1)
17141716
assert ax.get_zlim() == (1, 2)
17151717

17161718
with pytest.raises(
1717-
TypeError, match="Cannot pass both 'bottom' and 'zmin'"):
1719+
TypeError, match="Cannot pass both 'lower' and 'min'"):
17181720
ax.set_zlim(bottom=0, zmin=1)
17191721
with pytest.raises(
1720-
TypeError, match="Cannot pass both 'top' and 'zmax'"):
1722+
TypeError, match="Cannot pass both 'upper' and 'max'"):
17211723
ax.set_zlim(top=0, zmax=1)
17221724

17231725

@@ -1777,13 +1779,13 @@ def convert_lim(dmin, dmax):
17771779
("zoom", MouseButton.LEFT, 'x', # zoom in
17781780
((-0.01, 0.10), (-0.03, 0.08), (-0.06, 0.06))),
17791781
("zoom", MouseButton.LEFT, 'y', # zoom in
1780-
((-0.07, 0.04), (-0.03, 0.08), (0.00, 0.11))),
1782+
((-0.07, 0.05), (-0.04, 0.08), (0.00, 0.12))),
17811783
("zoom", MouseButton.RIGHT, None, # zoom out
1782-
((-0.09, 0.15), (-0.07, 0.17), (-0.06, 0.18))),
1784+
((-0.09, 0.15), (-0.08, 0.17), (-0.07, 0.18))),
17831785
("pan", MouseButton.LEFT, None,
1784-
((-0.70, -0.58), (-1.03, -0.91), (-1.27, -1.15))),
1786+
((-0.70, -0.58), (-1.04, -0.91), (-1.27, -1.15))),
17851787
("pan", MouseButton.LEFT, 'x',
1786-
((-0.96, -0.84), (-0.58, -0.46), (-0.06, 0.06))),
1788+
((-0.97, -0.84), (-0.58, -0.46), (-0.06, 0.06))),
17871789
("pan", MouseButton.LEFT, 'y',
17881790
((0.20, 0.32), (-0.51, -0.39), (-1.27, -1.15)))])
17891791
def test_toolbar_zoom_pan(tool, button, key, expected):
@@ -1968,15 +1970,15 @@ def test_format_coord():
19681970
x = np.arange(10)
19691971
ax.plot(x, np.sin(x))
19701972
fig.canvas.draw()
1971-
assert ax.format_coord(0, 0) == 'x=1.8066, y=1.0367, z=−0.0553'
1973+
assert ax.format_coord(0, 0) == 'x=1.6944, y=1.0799, z=−0.0576'
19721974
# Modify parameters
19731975
ax.view_init(roll=30, vertical_axis="y")
19741976
fig.canvas.draw()
1975-
assert ax.format_coord(0, 0) == 'x=9.1651, y=−0.9215, z=−0.0359'
1977+
assert ax.format_coord(0, 0) == 'x=9.3595, y=−0.9599, z=−0.0374'
19761978
# Reset parameters
19771979
ax.view_init()
19781980
fig.canvas.draw()
1979-
assert ax.format_coord(0, 0) == 'x=1.8066, y=1.0367, z=−0.0553'
1981+
assert ax.format_coord(0, 0) == 'x=1.6944, y=1.0799, z=−0.0576'
19801982

19811983

19821984
def test_get_axis_position():

0 commit comments

Comments
 (0)