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

Commitb87772d

Browse files
author
Nathan Goldbaum
committed
add test for movie writing floating point roundoff issues
1 parent81b072a commitb87772d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

‎.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ addons:
1313
packages:
1414
-inkscape
1515
-libav-tools
16+
-libavcodec-extra-53
1617
-gdb
1718
-mencoder
1819
-dvipng

‎lib/matplotlib/animation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ def _adjust_frame_size(self):
288288
verbose.report('figure size (inches) has been adjusted '
289289
'from %s x %s to %s x %s'% (wo,ho,w,h),
290290
level='helpful')
291+
else:
292+
w,h=self.fig.get_size_inches()
291293
verbose.report('frame size in pixels is %s x %s'%self.frame_size,
292294
level='debug')
295+
returnw,h
293296

294297
defsetup(self,fig,outfile,dpi=None):
295298
'''
@@ -311,7 +314,7 @@ def setup(self, fig, outfile, dpi=None):
311314
ifdpiisNone:
312315
dpi=self.fig.dpi
313316
self.dpi=dpi
314-
self._adjust_frame_size()
317+
self._w,self._h=self._adjust_frame_size()
315318

316319
# Run here so that grab_frame() can write the data to a pipe. This
317320
# eliminates the need for temp files.
@@ -347,7 +350,7 @@ def grab_frame(self, **savefig_kwargs):
347350
verbose.report('MovieWriter.grab_frame: Grabbing frame.',
348351
level='debug')
349352
try:
350-
self._adjust_frame_size()
353+
self.fig.set_size_inches(self._w,self._h)
351354
# Tell the figure to save its data to the sink, using the
352355
# frame format and dpi.
353356
self.fig.savefig(self._frame_sink(),format=self.frame_format,

‎lib/matplotlib/tests/test_animation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ def test_save_animation_smoketest(tmpdir, writer, extension):
145145
ax.set_xlim(0,10)
146146
ax.set_ylim(-1,1)
147147

148+
dpi=None
149+
codec=None
150+
ifwriter=='ffmpeg':
151+
# Issue #8253
152+
fig.set_size_inches((10.85,9.2000000000000011))
153+
dpi=100.
154+
codec='h264'
155+
148156
definit():
149157
line.set_data([], [])
150158
returnline,
@@ -160,7 +168,8 @@ def animate(i):
160168
withtmpdir.as_cwd():
161169
anim=animation.FuncAnimation(fig,animate,init_func=init,frames=5)
162170
try:
163-
anim.save('movie.'+extension,fps=30,writer=writer,bitrate=500)
171+
anim.save('movie.'+extension,fps=30,writer=writer,bitrate=500,
172+
dpi=dpi,codec=codec)
164173
exceptUnicodeDecodeError:
165174
pytest.xfail("There can be errors in the numpy import stack, "
166175
"see issues #1891 and #2679")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp