8000 added explicit call and more tests #16501 · matplotlib/matplotlib@377abe0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 377abe0

Browse files
committed
added explicit call and more tests #16501
1 parent 315a522 commit 377abe0

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -987,27 +987,31 @@ def set_thetalim(self, *args, **kwargs):
987987
where minval and maxval are the minimum and maximum limits. Values are
988988
wrapped in to the range :math:`[0, 2\pi]` (in radians), so for example
989989
it is possible to do ``set_thetalim(-np.pi / 2, np.pi / 2)`` to have
990-
8000 an axes symmetric around 0. If not within range :math:`[0, 2\pi]` a
991-
ValueError is raised.
990+
an axes symmetric around 0. A ValueError is raised if the absolute
991+
angle difference is larger than :math:2\pi.
992992
"""
993-
thetamin = 0
994-
thetamax = 0
993+
thetamin = None
994+
thetamax = None
995+
left = None
996+
right = None
997+
995998
if 'thetamin' in kwargs:
996999
thetamin = np.deg2rad(kwargs.pop('thetamin'))
997-
kwargs['xmin'] = thetamin
9981000
if 'thetamax' in kwargs:
9991001
thetamax = np.deg2rad(kwargs.pop('thetamax'))
1000-
kwargs['xmax'] = thetamax
10011002

1002-
if args.__len__() == 2:
1003+
if len(args) == 2:
10031004
if args[0] is not None and args[1] is not None:
1004-
if(abs(args[1] - args[0]) > 2 * np.pi):
1005+
left = args[0]
1006+
right = args[1]
1007+
if(abs(right - left) > 2 * np.pi):
10051008
raise ValueError('Cannot pass angle range > 2 pi')
10061009

1007-
if 'xmin' in kwargs and 'xmax' in kwargs:
1010+
if(thetamin is not None and thetamax is not None):
10081011
if(abs(thetamax - thetamin) > 2 * np.pi):
10091012
raise ValueError('Cannot pass angle range > 2 pi')
1010-
return tuple(np.rad2deg(self.set_xlim(*args, **kwargs)))
1013+
return tuple(np.rad2deg(self.set_xlim(left=left, right=right,
1014+
xmin=thetamin, xmax=thetamax)))
10111015

10121016
def set_theta_offset(self, offset):
10131017
"""

lib/matplotlib/tests/test_subplots.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,23 @@ def test_dont_mutate_kwargs():
175175
assert gridspec_kw == {'width_ratios': [1, 2]}
176176

177177

178-
def test_subplot_theta_min_max():
178+
def test_subplot_theta_min_max_raise():
179179
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
180180
ax = plt.subplot(111, projection='polar')
181181
ax.set_thetalim(thetamin=800, thetamax=400)
182182

183183

184-
def test_subplot_theta_range():
184+
def test_subplot_theta_min_max_non_raise():
185+
ax = plt.subplot(111, projection='polar')
186+
ax.set_thetalim(thetamin=800, thetamax=440)
187+
188+
189+
def test_subplot_theta_range_raise():
185190
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
186191
ax = plt.subplot(111, projection='polar')
187192
ax.set_thetalim(0, 3 * numpy.pi)
193+
194+
195+
def test_subplot_theta_range_normal_non_raise():
196+
ax = plt.subplot(111, projection='polar')
197+
ax.set_thetalim(0, 2 * numpy.pi)

0 commit comments

Comments
 (0)
0