Skip to content

Commit ee2d046

Browse files
authored
Merge pull request #17195 from anntzer/polartests
Fix polar tests.
2 parents 7f670ed + ba4d740 commit ee2d046

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

lib/matplotlib/projections/polar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ def set_thetalim(self, *args, **kwargs):
10611061

10621062
if thetamin is not None and thetamax is not None:
10631063
if abs(thetamax - thetamin) > 2 * np.pi:
1064-
raise ValueError('The angle range must be<= 360 degrees')
1064+
raise ValueError('The angle range must be <= 360 degrees')
10651065
return tuple(np.rad2deg(self.set_xlim(left=left, right=right,
10661066
xmin=thetamin, xmax=thetamax)))
10671067

lib/matplotlib/tests/test_polar.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import numpy as np
2+
import pytest
3+
4+
from matplotlib import pyplot as plt
5+
6+
7+
def test_thetalim_valid_invalid():
8+
ax = plt.subplot(projection='polar')
9+
ax.set_thetalim(0, 2 * np.pi) # doesn't raise.
10+
ax.set_thetalim(thetamin=800, thetamax=440) # doesn't raise.
11+
with pytest.raises(ValueError, match='The angle range must be <= 2 pi'):
12+
ax.set_thetalim(0, 3 * np.pi)
13+
with pytest.raises(ValueError,
14+
match='The angle range must be <= 360 degrees'):
15+
ax.set_thetalim(thetamin=800, thetamax=400)

lib/matplotlib/tests/test_subplots.py

-23
Original file line numberDiff line numberDiff line change
@@ -173,26 +173,3 @@ def test_dont_mutate_kwargs():
173173
gridspec_kw=gridspec_kw)
174174
assert subplot_kw == {'sharex': 'all'}
175175
assert gridspec_kw == {'width_ratios': [1, 2]}
176-
177-
178-
def test_subplot_theta_min_max_raise():
179-
with pytest.raises(ValueError, match='The angle range ' +
180-
'must be<= 360 degrees'):
181-
ax = plt.subplot(111, projection='polar')
182-
ax.set_thetalim(thetamin=800, thetamax=400)
183-
184-
185-
def test_subplot_theta_min_max_non_raise():
186-
ax = plt.subplot(111, projection='polar')
187-
ax.set_thetalim(thetamin=800, thetamax=440)
188-
189-
190-
def test_subplot_theta_range_raise():
191-
with pytest.raises(ValueError, match='The angle range must be <= 2 pi'):
192-
ax = plt.subplot(111, projection='polar')
193-
ax.set_thetalim(0, 3 * numpy.pi)
194-
195-
196-
def test_subplot_theta_range_normal_non_raise():
197-
ax = plt.subplot(111, projection='polar')
198-
ax.set_thetalim(0, 2 * numpy.pi)

0 commit comments

Comments
 (0)