Skip to content

Commit f9cccde

Browse files
committed
Replace some polar baseline images by check_figures_equal.
1 parent 667a100 commit f9cccde

13 files changed

+38
-6195
lines changed
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/polar_units.svg

-1,685
This file was deleted.
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/polar_units_2.svg

-1,794
This file was deleted.
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/polar_wrap_180.svg

-1,335
This file was deleted.
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/polar_wrap_360.svg

-1,357
This file was deleted.

lib/matplotlib/tests/test_axes.py

+38-24
Original file line numberDiff line numberDiff line change
@@ -628,44 +628,58 @@ def test_const_xy():
628628
plt.plot(np.ones(10), np.ones(10), 'o')
629629

630630

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

640-
fig = plt.figure()
641-
plt.subplot(111, polar=True)
642-
plt.polar(np.deg2rad([2, -2]), [0.2, 0.1], "b.-")
643-
plt.polar(np.deg2rad([2, 358]), [0.2, 0.1], "g.-")
644-
plt.polar(np.deg2rad([358, 2]), [0.2, 0.1], "r.-")
645-
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])
637+
638+
@check_figures_equal()
639+
def test_polar_wrap(fig_test, fig_ref):
640+
ax = fig_test.add_subplot(projection="polar")
641+
ax.plot(np.deg2rad([179, -179]), [0.2, 0.1])
642+
ax.plot(np.deg2rad([2, -2]), [0.2, 0.1])
643+
ax = fig_ref.add_subplot(projection="polar")
644+
ax.plot(np.deg2rad([179, 181]), [0.2, 0.1])
645+
ax.plot(np.deg2rad([2, 358]), [0.2, 0.1])
646646

647647

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

653-
deg = units.deg
654-
km = units.km
655+
plt.figure(fig_test.number)
656+
plt.polar([x * units.deg for x in xs], ys)
655657

656-
xs = [30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg]
657-
ys = [1.0, 2.0, 3.0, 4.0]
658+
ax = fig_ref.add_subplot(projection="polar")
659+
ax.plot(np.deg2rad(xs), ys)
660+
ax.set(xlabel="deg")
658661

659-
plt.figure()
660-
plt.polar(xs, ys, color="blue")
661662

662-
plt.figure()
663-
# make sure runits and theta units work
664-
ykm = [y*km for y in ys]
665-
plt.polar(xs, ykm, color="blue", thetaunits="rad", runits="km")
663+
@check_figures_equal()
664+
def test_polar_units_2(fig_test, fig_ref):
665+
import matplotlib.testing.jpl_units as units
666+
units.register()
667+
xs = [30.0, 45.0, 60.0, 90.0]
668+
xs_deg = [x * units.deg for x in xs]
669+
ys = [1.0, 2.0, 3.0, 4.0]
670+
ys_km = [y * units.km for y in ys]
671+
672+
plt.figure(fig_test.number)
673+
# test {theta,r}units.
674+
plt.polar(xs_deg, ys_km, thetaunits="rad", runits="km")
666675
assert isinstance(plt.gca().get_xaxis().get_major_formatter(),
667676
units.UnitDblFormatter)
668677

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

670684
@image_comparison(['polar_rmin'], style='default')
671685
def test_polar_rmin():

0 commit comments

Comments
 (0)