Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ba152a

Browse filesBrowse files
committed
TST: Parametrize new category bytes tests.
1 parent a29e26d commit 3ba152a
Copy full SHA for 3ba152a

File tree

Expand file treeCollapse file tree

1 file changed

+18
-46
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-46
lines changed

‎lib/matplotlib/tests/test_category.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_category.py
+18-46Lines changed: 18 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -188,62 +188,34 @@ def test_plot_1d_missing(self):
188188

189189
@cleanup
190190
@pytest.mark.usefixtures("data")
191-
def test_plot_bytes(self):
191+
@pytest.mark.parametrize("bins",
192+
[['a', 'b', 'c', 'a'],
193+
[b'a', b'b', b'c', b'a'],
194+
np.array([b'a', b'b', b'c', b'a'])])
195+
def test_plot_bytes(self, bins):
192196
counts = np.array([4, 6, 5, 1])
193-
fig, ax = plt.subplots(ncols=3)
194-
195-
ax[0].bar(self.d, counts)
196-
197-
types = [v.encode('ascii') for v in self.d]
198-
ax[1].bar(types, counts)
199-
200-
types = np.array(types)
201-
ax[2].bar(types, counts)
202197

198+
fig, ax = plt.subplots()
199+
ax.bar(bins, counts)
203200
fig.canvas.draw()
204201

205-
# All three plots should look like the string one.
206-
self.axis_test(ax[1].xaxis,
207-
ax[0].xaxis.get_majorticklocs(),
208-
lt(ax[0].xaxis.get_majorticklabels()),
209-
ax[0].xaxis.unit_data)
210-
self.axis_test(ax[2].xaxis,
211-
ax[0].xaxis.get_majorticklocs(),
212-
lt(ax[0].xaxis.get_majorticklabels()),
213-
ax[0].xaxis.unit_data)
202+
self.axis_test(ax.xaxis, self.dticks, self.dlabels, self.dunit_data)
214203

215204
@cleanup
216-
def test_plot_numlike(self):
205+
@pytest.mark.parametrize("bins",
206+
[['1', '11', '3', '1'],
207+
np.array(['1', '11', '3', '1']),
208+
[b'1', b'11', b'3', b'1'],
209+
np.array([b'1', b'11', b'3', b'1'])])
210+
def test_plot_numlike(self, bins):
217211
counts = np.array([4, 6, 5, 1])
218-
fig, ax = plt.subplots(ncols=4)
219-
220-
types = ['1', '11', '3', '1']
221-
ax[0].bar(types, counts)
222-
223-
types = np.array(types)
224-
ax[1].bar(types, counts)
225-
226-
types = [b'1', b'11', b'3', b'1']
227-
ax[2].bar(types, counts)
228-
229-
types = np.array(types)
230-
ax[3].bar(types, counts)
231212

213+
fig, ax = plt.subplots()
214+
ax.bar(bins, counts)
232215
fig.canvas.draw()
233216

234-
# All four plots should look like the string one.
235-
self.axis_test(ax[1].xaxis,
236-
ax[0].xaxis.get_majorticklocs(),
237-
lt(ax[0].xaxis.get_majorticklabels()),
238-
ax[0].xaxis.unit_data)
239-
self.axis_test(ax[2].xaxis,
240-
ax[0].xaxis.get_majorticklocs(),
241-
lt(ax[0].xaxis.get_majorticklabels()),
242-
ax[0].xaxis.unit_data)
243-
self.axis_test(ax[3].xaxis,
244-
ax[0].xaxis.get_majorticklocs(),
245-
lt(ax[0].xaxis.get_majorticklabels()),
246-
ax[0].xaxis.unit_data)
217+
unitmap = MockUnitData([('1', 0), ('11', 1), ('3', 2)])
218+
self.axis_test(ax.xaxis, [0, 1, 2], ['1', '11', '3'], unitmap)
247219

248220
@cleanup
249221
@pytest.mark.usefixtures("data", "missing_data")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.