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

Skip to content

Replace some polar baseline images by check_figures_equal. #14888

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
Sep 3, 2019
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
Binary file not shown.
Binary file not shown.
1,685 changes: 0 additions & 1,685 deletions lib/matplotlib/tests/baseline_images/test_axes/polar_units.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
1,794 changes: 0 additions & 1,794 deletions lib/matplotlib/tests/baseline_images/test_axes/polar_units_2.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
1,335 changes: 0 additions & 1,335 deletions lib/matplotlib/tests/baseline_images/test_axes/polar_wrap_180.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
1,357 changes: 0 additions & 1,357 deletions lib/matplotlib/tests/baseline_images/test_axes/polar_wrap_360.svg

This file was deleted.

62 changes: 38 additions & 24 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,44 +634,58 @@ def test_const_xy():
plt.plot(np.ones(10), np.ones(10), 'o')


@image_comparison(['polar_wrap_180', 'polar_wrap_360'], style='default')
def test_polar_wrap():
def test_polar_twice():
fig = plt.figure()
plt.subplot(111, polar=True)
plt.polar(np.deg2rad([179, -179]), [0.2, 0.1], "b.-")
plt.polar(np.deg2rad([179, 181]), [0.2, 0.1], "g.-")
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])
plt.polar([1, 2], [.1, .2])
plt.polar([3, 4], [.3, .4])
assert len(fig.axes) == 1, 'More than one polar axes created.'

fig = plt.figure()
plt.subplot(111, polar=True)
plt.polar(np.deg2rad([2, -2]), [0.2, 0.1], "b.-")
plt.polar(np.deg2rad([2, 358]), [0.2, 0.1], "g.-")
plt.polar(np.deg2rad([358, 2]), [0.2, 0.1], "r.-")
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])

@check_figures_equal()
def test_polar_wrap(fig_test, fig_ref):
ax = fig_test.add_subplot(projection="polar")
ax.plot(np.deg2rad([179, -179]), [0.2, 0.1])
ax.plot(np.deg2rad([2, -2]), [0.2, 0.1])
ax = fig_ref.add_subplot(projection="polar")
ax.plot(np.deg2rad([179, 181]), [0.2, 0.1])
ax.plot(np.deg2rad([2, 358]), [0.2, 0.1])


@image_comparison(['polar_units', 'polar_units_2'], style='default')
def test_polar_units():
@check_figures_equal()
def test_polar_units_1(fig_test, fig_ref):
import matplotlib.testing.jpl_units as units
units.register()
xs = [30.0, 45.0, 60.0, 90.0]
ys = [1.0, 2.0, 3.0, 4.0]

deg = units.deg
km = units.km
plt.figure(fig_test.number)
plt.polar([x * units.deg for x in xs], ys)

xs = [30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg]
ys = [1.0, 2.0, 3.0, 4.0]
ax = fig_ref.add_subplot(projection="polar")
ax.plot(np.deg2rad(xs), ys)
ax.set(xlabel="deg")

plt.figure()
plt.polar(xs, ys, color="blue")

plt.figure()
# make sure runits and theta units work
ykm = [y*km for y in ys]
plt.polar(xs, ykm, color="blue", thetaunits="rad", runits="km")
@check_figures_equal()
def test_polar_units_2(fig_test, fig_ref):
import matplotlib.testing.jpl_units as units
units.register()
xs = [30.0, 45.0, 60.0, 90.0]
xs_deg = [x * units.deg for x in xs]
ys = [1.0, 2.0, 3.0, 4.0]
ys_km = [y * units.km for y in ys]

plt.figure(fig_test.number)
# test {theta,r}units.
plt.polar(xs_deg, ys_km, thetaunits="rad", runits="km")
assert isinstance(plt.gca().get_xaxis().get_major_formatter(),
units.UnitDblFormatter)

ax = fig_ref.add_subplot(projection="polar")
ax.plot(np.deg2rad(xs), ys)
ax.xaxis.set_major_formatter(mticker.FuncFormatter("{:.12}".format))
ax.set(xlabel="rad", ylabel="km")


@image_comparison(['polar_rmin'], style='default')
def test_polar_rmin():
Expand Down