10000 changed order, remove braces on if and changed error message · matplotlib/matplotlib@a69db44 · GitHub
[go: up one dir, main page]

Skip to content

Commit a69db44

Browse files
committed
changed order, remove braces on if and changed error message
1 parent 377abe0 commit a69db44

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -988,28 +988,27 @@ def set_thetalim(self, *args, **kwargs):
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
990990
an axes symmetric around 0. A ValueError is raised if the absolute
991-
angle difference is larger than :math:2\pi.
991+
angle difference is larger than :math:`2\pi`.
992992
"""
993993
thetamin = None
994994
thetamax = None
995995
left = None
996996
right = None
997997

998+
if len(args) == 2:
999+
if args[0] is not None and args[1] is not None:
1000+
left, right = args
1001+
if abs(right - left) > 2 * np.pi:
1002+
raise ValueError('The angle range must be <= 2 pi')
1003+
9981004
if 'thetamin' in kwargs:
9991005
thetamin = np.deg2rad(kwargs.pop('thetamin'))
10001006
if 'thetamax' in kwargs:
10011007
thetamax = np.deg2rad(kwargs.pop('thetamax'))
10021008

1003-
if len(args) == 2:
1004-
if args[0] is not None and args[1] is not None:
1005-
left = args[0]
1006-
right = args[1]
1007-
if(abs(right - left) > 2 * np.pi):
1008-
raise ValueError('Cannot pass angle range > 2 pi')
1009-
1010-
if(thetamin is not None and thetamax is not None):
1011-
if(abs(thetamax - thetamin) > 2 * np.pi):
1012-
raise ValueError('Cannot pass angle range > 2 pi')
1009+
if thetamin is not None and thetamax is not None:
1010+
if abs(thetamax - thetamin) > 2 * np.pi:
1011+
raise ValueError('The angle range must be<= 360 degrees')
10131012
return tuple(np.rad2deg(self.set_xlim(left=left, right=right,
10141013
xmin=thetamin, xmax=thetamax)))
10151014

lib/matplotlib/tests/test_subplots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_dont_mutate_kwargs():
176176

177177

178178
def test_subplot_theta_min_max_raise():
179-
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
179+
with pytest.raises(ValueError, match='The angle range must be<= 360 degrees'):
180180
ax = plt.subplot(111, projection='polar')
181181
ax.set_thetalim(thetamin=800, thetamax=400)
182182

@@ -187,7 +187,7 @@ def test_subplot_theta_min_max_non_raise():
187187

188188

189189
def test_subplot_theta_range_raise():
190-
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
190+
with pytest.raises(ValueError, match='The angle range must be <= 2 pi'):
191191
ax = plt.subplot(111, projection='polar')
192192
ax.set_thetalim(0, 3 * numpy.pi)
193193

0 commit comments

Comments
 (0)
0