Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 972c44f

Browse files
author
Nathan Goldbaum
committed
add test for movie writing floating point roundoff issues
1 parent 0537b0d commit 972c44f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/tests/test_animation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def isAvailable(self):
130130
# matplotlib.testing.image_comparison
131131
@pytest.mark.parametrize('writer, extension', WRITER_OUTPUT)
132132
def test_save_animation_smoketest(tmpdir, writer, extension):
133+
mpl.rcParams['animation.codec'] = 'h264'
133134
try:
134135
# for ImageMagick the rcparams must be patched to account for
135136
# 'convert' being a built in MS tool, not the imagemagick
@@ -145,6 +146,12 @@ def test_save_animation_smoketest(tmpdir, writer, extension):
145146
ax.set_xlim(0, 10)
146147
ax.set_ylim(-1, 1)
147148

149+
dpi = None
150+
if writer == 'ffmpeg':
151+
# Issue #8253
152+
fig.set_size_inches((10.85, 9.2000000000000011))
153+
dpi = 100.
154+
148155
def init():
149156
line.set_data([], [])
150157
return line,
@@ -160,7 +167,8 @@ def animate(i):
160167
with tmpdir.as_cwd():
161168
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=5)
162169
try:
163-
anim.save('movie.' + extension, fps=30, writer=writer, bitrate=500)
170+
anim.save('movie.' + extension, fps=30, writer=writer, bitrate=500,
171+
dpi=dpi)
164172
except UnicodeDecodeError:
165173
pytest.xfail("There can be errors in the numpy import stack, "
166174
"see issues #1891 and #2679")

0 commit comments

Comments
 (0)