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

Skip to content

Commit 942ee4d

Browse files
committed
added unit tests for issue #16501
1 parent a6929f3 commit 942ee4d

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/matplotlib/projections/polar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,11 @@ def set_thetalim(self, *args, **kwargs):
10011001
if args.__len__() == 2:
10021002
if args[0] is not None and args[1] is not None:
10031003
if(abs(args[1] - args[0]) > 2 * np.pi):
1004-
raise TypeError('Cannot pass angle range > 2 pi')
1004+
raise ValueError('Cannot pass angle range > 2 pi')
10051005

10061006
if 'xmin' in kwargs and 'xmax' in kwargs:
10071007
if(abs(thetamax - thetamin) > 2 * np.pi):
1008-
raise TypeError('Cannot pass angle range > 2 pi')
1008+
raise ValueError('Cannot pass angle range > 2 pi')
10091009
return tuple(np.rad2deg(self.set_xlim(*args, **kwargs)))
10101010

10111011
def set_theta_offset(self, offset):

lib/matplotlib/tests/test_subplots.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,13 @@ 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+
def test_subplot_theta_min_max():
178+
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
179+
ax = plt.subplot(111, projection='polar')
180+
ax.set_thetalim(thetamin = 800, thetamax=400)
181+
182+
def test_subplot_theta_range():
183+
with pytest.raises(ValueError, match="Cannot pass angle range > 2 pi"):
184+
ax = plt.subplot(111, projection='polar')
185+
ax.set_thetalim(0, 3 * numpy.pi)

0 commit comments

Comments
 (0)