|
1 | 1 | from __future__ import (absolute_import, division, print_function, |
2 | 2 | unicode_literals) |
3 | 3 |
|
4 | | -import six |
5 | 4 | from six.moves import xrange |
6 | 5 |
|
7 | | -from nose.tools import assert_equal, assert_true |
| 6 | +from numpy.testing import assert_equal |
8 | 7 | from matplotlib import rcParams |
9 | 8 | from matplotlib.testing.decorators import image_comparison, cleanup |
10 | 9 | from matplotlib.axes import Axes |
@@ -84,44 +83,42 @@ def test_gca(): |
84 | 83 | fig = plt.figure() |
85 | 84 |
|
86 | 85 | ax1 = fig.add_axes([0, 0, 1, 1]) |
87 | | - assert_true(fig.gca(projection='rectilinear') is ax1) |
88 | | - assert_true(fig.gca() is ax1) |
| 86 | + assert fig.gca(projection='rectilinear') is ax1 |
| 87 | + assert fig.gca() is ax1 |
89 | 88 |
|
90 | 89 | ax2 = fig.add_subplot(121, projection='polar') |
91 | | - assert_true(fig.gca() is ax2) |
92 | | - assert_true(fig.gca(polar=True)is ax2) |
| 90 | + assert fig.gca() is ax2 |
| 91 | + assert fig.gca(polar=True)is ax2 |
93 | 92 |
|
94 | 93 | ax3 = fig.add_subplot(122) |
95 | | - assert_true(fig.gca() is ax3) |
| 94 | + assert fig.gca() is ax3 |
96 | 95 |
|
97 | 96 | # the final request for a polar axes will end up creating one |
98 | 97 | # with a spec of 111. |
99 | 98 | with warnings.catch_warnings(record=True) as w: |
100 | 99 | warnings.simplefilter('always') |
101 | 100 | # Changing the projection will throw a warning |
102 | | - assert_true(fig.gca(polar=True) is not ax3) |
| 101 | + assert fig.gca(polar=True) is not ax3 |
103 | 102 | assert len(w) == 1 |
104 | | - assert_true(fig.gca(polar=True) is not ax2) |
| 103 | + assert fig.gca(polar=True) is not ax2 |
105 | 104 | assert_equal(fig.gca().get_geometry(), (1, 1, 1)) |
106 | 105 |
|
107 | 106 | fig.sca(ax1) |
108 | | - assert_true(fig.gca(projection='rectilinear') is ax1) |
109 | | - assert_true(fig.gca() is ax1) |
| 107 | + assert fig.gca(projection='rectilinear') is ax1 |
| 108 | + assert fig.gca() is ax1 |
110 | 109 |
|
111 | 110 |
|
112 | 111 | @image_comparison(baseline_images=['figure_suptitle']) |
113 | 112 | def test_suptitle(): |
114 | | - fig = plt.figure() |
115 | | - ax = fig.add_subplot(1, 1, 1) |
| 113 | + fig, _ = plt.subplots() |
116 | 114 | fig.suptitle('hello', color='r') |
117 | 115 | fig.suptitle('title', color='g', rotation='30') |
118 | 116 |
|
119 | 117 |
|
120 | 118 | @cleanup |
121 | 119 | def test_suptitle_fontproperties(): |
122 | 120 | from matplotlib.font_manager import FontProperties |
123 | | - fig = plt.figure() |
124 | | - ax = fig.add_subplot(1, 1, 1) |
| 121 | + fig, ax = plt.subplots() |
125 | 122 | fps = FontProperties(size='large', weight='bold') |
126 | 123 | txt = fig.suptitle('fontprops title', fontproperties=fps) |
127 | 124 | assert_equal(txt.get_fontsize(), fps.get_size_in_points()) |
@@ -153,7 +150,7 @@ def test_too_many_figures(): |
153 | 150 | with warnings.catch_warnings(record=True) as w: |
154 | 151 | warnings.simplefilter("always") |
155 | 152 | for i in range(rcParams['figure.max_open_warning'] + 1): |
156 | | - fig = plt.figure() |
| 153 | + plt.figure() |
157 | 154 | assert len(w) == 1 |
158 | 155 |
|
159 | 156 |
|
@@ -184,7 +181,7 @@ def _as_mpl_axes(self): |
184 | 181 | return MyAxes, {'myclass': self} |
185 | 182 |
|
186 | 183 | fig = plt.figure() |
187 | | - ax = fig.add_subplot(1, 1, 1, projection=MyClass()) |
| 184 | + fig.add_subplot(1, 1, 1, projection=MyClass()) |
188 | 185 | plt.close(fig) |
189 | 186 |
|
190 | 187 |
|
@@ -230,8 +227,3 @@ def test_figaspect(): |
230 | 227 | assert h / w == 0.5 |
231 | 228 | w, h = plt.figaspect(np.zeros((2, 2))) |
232 | 229 | assert h / w == 1 |
233 | | - |
234 | | - |
235 | | -if __name__ == "__main__": |
236 | | - import nose |
237 | | - nose.runmodule(argv=['-s', '--with-doctest'], exit=False) |
0 commit comments