8000 MAINT moved all remaining "f" modules to pytest by NelleV · Pull Request #7897 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MAINT moved all remaining "f" modules to pytest #7897

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 2 commits into from
Jan 23, 2017
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
1 change: 0 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_contour',
'matplotlib.tests.test_dates',
'matplotlib.tests.test_dviread',
'matplotlib.tests.test_figure',
'matplotlib.tests.test_font_manager',
'matplotlib.tests.test_gridspec',
'matplotlib.tests.test_image',
Expand Down
40 changes: 15 additions & 25 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import xrange

from nose.tools import assert_equal, assert_true
from numpy.testing import assert_equal
from matplotlib import rcParams
from matplotlib.testing.decorators import image_comparison, cleanup
from matplotlib.axes import Axes
Expand Down Expand Up @@ -58,7 +55,7 @@ def test_figure():
fig = plt.figure('today')
ax = fig.add_subplot(111)
ax.set_title(fig.get_label())
ax.plot(list(xrange(5)))
ax.plot(np.arange(5))
# plot red line in a different figure.
plt.figure('tomorrow')
plt.plot([0, 1], [1, 0], 'r')
Expand All @@ -84,44 +81,42 @@ def test_gca():
fig = plt.figure()

ax1 = fig.add_axes([0, 0, 1, 1])
assert_true(fig.gca(projection='rectilinear') is ax1)
assert_true(fig.gca() is ax1)
assert fig.gca(projection='rectilinear') is ax1
assert fig.gca() is ax1

ax2 = fig.add_subplot(121, projection='polar')
assert_true(fig.gca() is ax2)
assert_true(fig.gca(polar=True)is ax2)
assert fig.gca() is ax2
assert fig.gca(polar=True)is ax2

ax3 = fig.add_subplot(122)
assert_true(fig.gca() is ax3)
assert fig.gca() is ax3

# the final request for a polar axes will end up creating one
# with a spec of 111.
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
# Changing the projection will throw a warning
assert_true(fig.gca(polar=True) is not ax3)
assert fig.gca(polar=True) is not ax3
assert len(w) == 1
assert_true(fig.gca(polar=True) is not ax2)
assert fig.gca(polar=True) is not ax2
assert_equal(fig.gca().get_geometry(), (1, 1, 1))

fig.sca(ax1)
assert_true(fig.gca(projection='rectilinear') is ax1)
assert_true(fig.gca() is ax1)
assert fig.gca(projection='rectilinear') is ax1
assert fig.gca() is ax1


@image_comparison(baseline_images=['figure_suptitle'])
def test_suptitle():
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
fig, _ = plt.subplots()
fig.suptitle('hello', color='r')
fig.suptitle('title', color='g', rotation='30')


@cleanup
def test_suptitle_fontproperties():
from matplotlib.font_manager import FontProperties
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
fig, ax = plt.subplots()
fps = FontProperties(size='large', weight='bold')
txt = fig.suptitle('fontprops title', fontproperties=fps)
assert_equal(txt.get_fontsize(), fps.get_size_in_points())
Expand Down Expand Up @@ -153,7 +148,7 @@ def test_too_many_figures():
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
for i in range(rcParams['figure.max_open_warning'] + 1):
fig = plt.figure()
plt.figure()
assert len(w) == 1


Expand Down Expand Up @@ -184,7 +179,7 @@ def _as_mpl_axes(self):
return MyAxes, {'myclass': self}

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=MyClass())
fig.add_subplot(1, 1, 1, projection=MyClass())
plt.close(fig)


Expand Down Expand Up @@ -230,8 +225,3 @@ def test_figaspect():
assert h / w == 0.5
w, h = plt.figaspect(np.zeros((2, 2)))
assert h / w == 1


if __name__ == "__main__":
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
0