8000 Fix polar tests. by anntzer · Pull Request #17195 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix polar tests. #17195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
2 changes: 1 addition & 1 deletion lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def set_thetalim(self, *args, **kwargs):

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

Expand Down
15 changes: 15 additions & 0 deletions lib/matplotlib/tests/test_polar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import numpy as np
import pytest

from matplotlib import pyplot as plt


def test_thetalim_valid_invalid():
ax = plt.subplot(projection='polar')
ax.set_thetalim(0, 2 * np.pi) # doesn't raise.
ax.set_thetalim(thetamin=800, thetamax=440) # doesn't raise.
with pytest.raises(ValueError, match='The angle range must be <= 2 pi'):
ax.set_thetalim(0, 3 * np.pi)
with pytest.raises(ValueError,
match='The angle range must be <= 360 degrees'):
ax.set_thetalim(thetamin=800, thetamax=400)
23 changes: 0 additions & 23 deletions lib/matplotlib/tests/test_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,3 @@ def test_dont_mutate_kwargs():
gridspec_kw=gridspec_kw)
assert subplot_kw == {'sharex': 'all'}
assert gridspec_kw == {'width_ratios': [1, 2]}


def test_subplot_theta_min_max_raise():
with pytest.raises(ValueError, match='The angle range ' +
'must be<= 360 degrees'):
ax = plt.subplot(111, projection='polar')
ax.set_thetalim(thetamin=800, thetamax=400)


def test_subplot_theta_min_max_non_raise():
ax = plt.subplot(111, projection='polar')
ax.set_thetalim(thetamin=800, thetamax=440)


def test_subplot_theta_range_raise():
with pytest.raises(ValueError, match='The angle range must be <= 2 pi'):
ax = plt.subplot(111, projection='polar')
ax.set_thetalim(0, 3 * numpy.pi)


def test_subplot_theta_range_normal_non_raise():
ax = plt.subplot(111, projection='polar')
ax.set_thetalim(0, 2 * numpy.pi)
0