Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd4a34fc

Browse files
committed
TST: convertplt.draw() calls in test suite to explicit draws
This ensures that if the test relied on the draw actually happening, it stillhappens.
1 parentf642052 commitd4a34fc

File tree

9 files changed

+22
-24
lines changed

9 files changed

+22
-24
lines changed

‎lib/matplotlib/tests/test_animation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,5 @@ def animate(i):
358358
returnreturn_value
359359

360360
withpytest.raises(RuntimeError):
361-
animation.FuncAnimation(fig,animate,blit=True)
361+
anim=animation.FuncAnimation(fig,animate,blit=True)
362+
fig.canvas.draw()

‎lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ def test_twinx_cla():
289289
fig,ax=plt.subplots()
290290
ax2=ax.twinx()
291291
ax3=ax2.twiny()
292-
plt.draw()
292+
fig.canvas.draw()
293+
293294
assertnotax2.xaxis.get_visible()
294295
assertnotax2.patch.get_visible()
295296
ax2.cla()
@@ -477,7 +478,8 @@ def test_autoscale_log_shared():
477478
ax2.semilogx(x,x)
478479
ax1.autoscale(tight=True)
479480
ax2.autoscale(tight=True)
480-
plt.draw()
481+
fig.canvas.draw()
482+
481483
lims= (x[1],x[-1])
482484
assert_allclose(ax1.get_xlim(),lims)
483485
assert_allclose(ax1.get_ylim(),lims)
@@ -4097,7 +4099,7 @@ def test_eventplot_problem_kwargs(recwarn):
40974099
deftest_empty_eventplot():
40984100
fig,ax=plt.subplots(1,1)
40994101
ax.eventplot([[]],colors=[(0.0,0.0,0.0,0.0)])
4100-
plt.draw()
4102+
fig.canvas.draw()
41014103

41024104

41034105
@pytest.mark.parametrize('data', [[[]], [[], [0,1]], [[0,1], []]])
@@ -4107,7 +4109,7 @@ def test_eventplot_orientation(data, orientation):
41074109
opts= {}iforientationisNoneelse {'orientation':orientation}
41084110
fig,ax=plt.subplots(1,1)
41094111
ax.eventplot(data,**opts)
4110-
plt.draw()
4112+
fig.canvas.draw()
41114113

41124114

41134115
@image_comparison(['marker_styles.png'],remove_text=True)
@@ -4261,7 +4263,7 @@ def test_axline_args():
42614263
ax.set_yscale('linear')
42624264
withpytest.raises(ValueError):
42634265
ax.axline((0,0), (0,0))# two identical points are not allowed
4264-
plt.draw()
4266+
fig.canvas.draw()
42654267

42664268

42674269
@image_comparison(['vlines_basic','vlines_with_nan','vlines_masked'],
@@ -4834,7 +4836,7 @@ def test_shared_with_aspect_2():
48344836
axs[0].set_aspect(2,share=True)
48354837
axs[0].plot([1,2], [3,4])
48364838
axs[1].plot([3,4], [1,2])
4837-
plt.draw()# Trigger apply_aspect().
4839+
fig.canvas.draw()
48384840
assertaxs[0].get_xlim()==axs[1].get_xlim()
48394841
assertaxs[0].get_ylim()==axs[1].get_ylim()
48404842

@@ -4847,7 +4849,7 @@ def test_shared_with_aspect_3():
48474849
axs[1].set_aspect(0.5,adjustable=adjustable)
48484850
axs[0].plot([1,2], [3,4])
48494851
axs[1].plot([3,4], [1,2])
4850-
plt.draw()# Trigger apply_aspect().
4852+
fig.canvas.draw()
48514853
assertaxs[0].get_xlim()!=axs[1].get_xlim()
48524854
assertaxs[0].get_ylim()==axs[1].get_ylim()
48534855
fig_aspect=fig.bbox_inches.height/fig.bbox_inches.width
@@ -5149,7 +5151,8 @@ def test_subsampled_ticklabels():
51495151
ax.xaxis.set_ticks(np.arange(10)+0.1)
51505152
ax.locator_params(nbins=5)
51515153
ax.xaxis.set_ticklabels([cforcin"bcdefghijk"])
5152-
plt.draw()
5154+
fig.canvas.draw()
5155+
51535156
labels= [t.get_text()fortinax.xaxis.get_ticklabels()]
51545157
assertlabels== ['b','d','f','h','j']
51555158

‎lib/matplotlib/tests/test_collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def test_picking():
476476

477477
deftest_linestyle_single_dashes():
478478
plt.scatter([0,1,2], [0,1,2],linestyle=(0., [2.,2.]))
479-
plt.draw()
479+
plt.gcf().canvas.draw()
480480

481481

482482
@image_comparison(['size_in_xy.png'],remove_text=True)

‎lib/matplotlib/tests/test_colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def test_mappable_no_alpha():
601601
sm=cm.ScalarMappable(norm=mcolors.Normalize(),cmap='viridis')
602602
fig.colorbar(sm)
603603
sm.set_cmap('plasma')
604-
plt.draw()
604+
fig.canvas.draw()
605605

606606

607607
deftest_colorbar_label():

‎lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ def test_autoscale_masked():
893893
# Test for #2336. Previously fully masked data would trigger a ValueError.
894894
data=np.ma.masked_all((12,20))
895895
plt.pcolor(data)
896-
plt.draw()
896+
plt.gcf().canvas.draw()
897897

898898

899899
@image_comparison(['light_source_shading_topo.png'])

‎lib/matplotlib/tests/test_pickle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_polar():
143143
fig=plt.gcf()
144144
pf=pickle.dumps(fig)
145145
pickle.loads(pf)
146-
plt.draw()
146+
plt.gcf().canvas.draw()
147147

148148

149149
classTransformBlob:

‎lib/matplotlib/tests/test_spines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_label_without_ticks():
119119
ax.set_xlabel('x label')
120120
ax.xaxis.set_ticks([])
121121
ax.yaxis.set_ticks([])
122-
plt.draw()
122+
fig.canvas.draw()
123123

124124
spine=ax.spines.left
125125
spinebbox=spine.get_transform().transform_path(

‎lib/matplotlib/tests/test_text.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,8 @@ def test_annotation_negative_fig_coords():
446446

447447

448448
deftest_text_stale():
449-
# A version of draw_all that draws even when interactive is off
450-
defdraw_all_when_not_interactive():
451-
forf_mgrinplt._pylab_helpers.Gcf.get_all_fig_managers():
452-
iff_mgr.canvas.figure.stale:
453-
f_mgr.canvas.draw()
454-
455449
fig, (ax1,ax2)=plt.subplots(1,2)
456-
draw_all_when_not_interactive()
450+
fig.canvas.draw()
457451
assertnotax1.stale
458452
assertnotax2.stale
459453
assertnotfig.stale
@@ -468,7 +462,7 @@ def draw_all_when_not_interactive():
468462
assertann1.stale
469463
assertfig.stale
470464

471-
draw_all_when_not_interactive()
465+
fig.canvas.draw()
472466
assertnotax1.stale
473467
assertnotax2.stale
474468
assertnotfig.stale

‎lib/matplotlib/tests/test_transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def transform_non_affine(self, path):
4343
my_trans=AssertingNonAffineTransform()
4444
ax=plt.axes()
4545
plt.plot(np.arange(10),transform=my_trans+ax.transData)
46-
plt.draw()
46+
ax.figure.canvas.draw()
4747
# enable the transform to raise an exception if it's non-affine transform
4848
# method is triggered again.
4949
my_trans.raise_on_transform=True
5050
ax.transAxes.invalidate()
51-
plt.draw()
51+
ax.figure.canvas.draw()
5252

5353

5454
deftest_external_transform_api():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp