Skip to content

Commit 0469c1a

Browse files
authored
Merge pull request #17536 from QuLogic/consolidate-tests
Consolidate some tests and fix a couple typos
2 parents a0b7068 + b197b7d commit 0469c1a

File tree

8 files changed

+32
-55
lines changed

8 files changed

+32
-55
lines changed
Binary file not shown.
Binary file not shown.

lib/matplotlib/tests/test_axes.py

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,10 +2236,10 @@ def test_bxp_rangewhis():
22362236
_bxp_test_helper(stats_kwargs=dict(whis=[0, 100]))
22372237

22382238

2239-
@image_comparison(['bxp_precentilewhis.png'],
2239+
@image_comparison(['bxp_percentilewhis.png'],
22402240
savefig_kwarg={'dpi': 40},
22412241
style='default')
2242-
def test_bxp_precentilewhis():
2242+
def test_bxp_percentilewhis():
22432243
_bxp_test_helper(stats_kwargs=dict(whis=[5, 95]))
22442244

22452245

@@ -2610,28 +2610,24 @@ def test_boxplot_no_weird_whisker():
26102610
ax1.xaxis.grid(False)
26112611

26122612

2613-
def test_boxplot_bad_medians_1():
2613+
def test_boxplot_bad_medians():
26142614
x = np.linspace(-7, 7, 140)
26152615
x = np.hstack([-25, x, 25])
26162616
fig, ax = plt.subplots()
26172617
with pytest.raises(ValueError):
26182618
ax.boxplot(x, usermedians=[1, 2])
2619-
2620-
2621-
def test_boxplot_bad_medians_2():
2622-
x = np.linspace(-7, 7, 140)
2623-
x = np.hstack([-25, x, 25])
2624-
fig, ax = plt.subplots()
26252619
with pytest.raises(ValueError):
26262620
ax.boxplot([x, x], usermedians=[[1, 2], [1, 2]])
26272621

26282622

2629-
def test_boxplot_bad_ci_1():
2623+
def test_boxplot_bad_ci():
26302624
x = np.linspace(-7, 7, 140)
26312625
x = np.hstack([-25, x, 25])
26322626
fig, ax = plt.subplots()
26332627
with pytest.raises(ValueError):
26342628
ax.boxplot([x, x], conf_intervals=[[1, 2]])
2629+
with pytest.raises(ValueError):
2630+
ax.boxplot([x, x], conf_intervals=[[1, 2], [1]])
26352631

26362632

26372633
def test_boxplot_zorder():
@@ -2641,14 +2637,6 @@ def test_boxplot_zorder():
26412637
assert ax.boxplot(x, zorder=10)['boxes'][0].get_zorder() == 10
26422638

26432639

2644-
def test_boxplot_bad_ci_2():
2645-
x = np.linspace(-7, 7, 140)
2646-
x = np.hstack([-25, x, 25])
2647-
fig, ax = plt.subplots()
2648-
with pytest.raises(ValueError):
2649-
ax.boxplot([x, x], conf_intervals=[[1, 2], [1]])
2650-
2651-
26522640
def test_boxplot_marker_behavior():
26532641
plt.rcParams['lines.marker'] = 's'
26542642
plt.rcParams['boxplot.flierprops.marker'] = 'o'
@@ -4526,6 +4514,28 @@ def test_pie_textprops():
45264514
assert tx.get_color() == textprops["color"]
45274515

45284516

4517+
def test_pie_get_negative_values():
4518+
# Test the ValueError raised when feeding negative values into axes.pie
4519+
fig, ax = plt.subplots()
4520+
with pytest.raises(ValueError):
4521+
ax.pie([5, 5, -3], explode=[0, .1, .2])
4522+
4523+
4524+
def test_normalize_kwarg_warn_pie():
4525+
fig, ax = plt.subplots()
4526+
with pytest.warns(MatplotlibDeprecationWarning):
4527+
ax.pie(x=[0], normalize=None)
4528+
4529+
4530+
def test_normalize_kwarg_pie():
4531+
fig, ax = plt.subplots()
4532+
x = [0.3, 0.3, 0.1]
4533+
t1 = ax.pie(x=x, normalize=True)
4534+
assert abs(t1[0][-1].theta2 - 360.) < 1e-3
4535+
t2 = ax.pie(x=x, normalize=False)
4536+
assert abs(t2[0][-1].theta2 - 360.) > 1e-3
4537+
4538+
45294539
@image_comparison(['set_get_ticklabels.png'])
45304540
def test_set_get_ticklabels():
45314541
# test issue 2246
@@ -6234,13 +6244,6 @@ def test_bbox_aspect_axes_init():
62346244
assert_allclose(sizes, sizes[0])
62356245

62366246

6237-
def test_pi_get_negative_values():
6238-
# Test the ValueError raised when feeding negative values into axes.pie
6239-
fig, ax = plt.subplots()
6240-
with pytest.raises(ValueError):
6241-
ax.pie([5, 5, -3], explode=[0, .1, .2])
6242-
6243-
62446247
def test_invisible_axes():
62456248
# invisible axes should not respond to events...
62466249
fig, ax = plt.subplots()
@@ -6301,18 +6304,3 @@ def test_polar_interpolation_steps_variable_r(fig_test, fig_ref):
63016304
l.get_path()._interpolation_steps = 100
63026305
fig_ref.add_subplot(projection="polar").plot(
63036306
np.linspace(0, np.pi/2, 101), np.linspace(1, 2, 101))
6304-
6305-
6306-
def test_normalize_kwarg_warn_pie():
6307-
fig, ax = plt.subplots()
6308-
with pytest.warns(MatplotlibDeprecationWarning):
6309-
ax.pie(x=[0], normalize=None)
6310-
6311-
6312-
def test_normalize_kwarg_pie():
6313-
fig, ax = plt.subplots()
6314-
x = [0.3, 0.3, 0.1]
6315-
t1 = ax.pie(x=x, normalize=True)
6316-
assert abs(t1[0][-1].theta2 - 360.) < 1e-3
6317-
t2 = ax.pie(x=x, normalize=False)
6318-
assert abs(t2[0][-1].theta2 - 360.) > 1e-3

lib/matplotlib/tests/test_image.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def test_interp_nearest_vs_none():
7878
ax2.set_title('interpolation nearest')
7979

8080

81-
def do_figimage(suppressComposite):
82-
"""Helper for the next two tests."""
81+
@pytest.mark.parametrize('suppressComposite', [False, True])
82+
@image_comparison(['figimage'], extensions=['png', 'pdf'])
83+
def test_figimage(suppressComposite):
8384
fig = plt.figure(figsize=(2, 2), dpi=100)
8485
fig.suppressComposite = suppressComposite
8586
x, y = np.ix_(np.arange(100) / 100.0, np.arange(100) / 100)
@@ -93,18 +94,6 @@ def do_figimage(suppressComposite):
9394
fig.figimage(img[::-1, ::-1], xo=100, yo=100, origin='lower')
9495

9596

96-
@image_comparison(['figimage-0'], extensions=['png', 'pdf'])
97-
def test_figimage0():
98-
suppressComposite = False
99-
do_figimage(suppressComposite)
100-
101-
102-
@image_comparison(['figimage-1'], extensions=['png', 'pdf'])
103-
def test_figimage1():
104-
suppressComposite = True
105-
do_figimage(suppressComposite)
106-
107-
10897
def test_image_python_io():
10998
fig, ax = plt.subplots()
11099
ax.plot([1, 2, 3])

lib/matplotlib/tests/test_mlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def test_apply_window_hanning_2D_axis1(self):
303303
assert x.shape == y.shape
304304
assert_allclose(yt, y, atol=1e-06)
305305

306-
def test_apply_window_hanning_2D__els1_axis1(self):
306+
def test_apply_window_hanning_2D_els1_axis1(self):
307307
x = np.random.standard_normal([10, 1000]) + 100.
308308
window = mlab.window_hanning(np.ones(x.shape[1]))
309309
window1 = mlab.window_hanning

0 commit comments

Comments
 (0)