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

Fix undefined name. Add animation tests.#10801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 2 commits intomatplotlib:masterfromanntzer:fix-undefined-name
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.appveyor.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,7 @@ install:
- activate test-environment
- echo %PYTHON_VERSION% %TARGET_ARCH%
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
- pip install -q "pytest!=3.3.0,>=3.2.0" "pytest-cov>=2.3.1" pytest-rerunfailures pytest-timeout pytest-xdist
- pip install -q "pytest>=3.4" "pytest-cov>=2.3.1" pytest-rerunfailures pytest-timeout pytest-xdist

# Apply patch to `subprocess` on Python versions > 2 and < 3.6.3
# https://github.com/matplotlib/matplotlib/issues/9176
Expand Down
8 changes: 5 additions & 3 deletions.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,14 +18,16 @@ addons:
paths:
- result_images.tar.bz2
apt:
sources:
- sourceline: ppa:jonathonf/ffmpeg-3
packages:
- cm-super
- dvipng
- ffmpeg
- gdb
- gir1.2-gtk-3.0
- graphviz
- inkscape
- libav-tools
- libcairo2
- libgeos-dev
- libgirepository-1.0.1
Expand All@@ -52,7 +54,7 @@ env:
- NUMPY=numpy
- PANDAS=
- PYPARSING=pyparsing
- PYTEST='pytest!=3.3.0,>=3.2.0'
- PYTEST='pytest>=3.4'
- PYTEST_COV=pytest-cov
- PYTEST_PEP8=
- SPHINX=sphinx
Expand All@@ -74,7 +76,7 @@ matrix:
- NUMPY=numpy==1.10.0
- PANDAS='pandas<0.21.0'
- PYPARSING=pyparsing==2.0.1
- PYTEST=pytest==3.1.0
- PYTEST=pytest==3.4
- PYTEST_COV=pytest-cov==2.3.1
- SPHINX=sphinx==1.3
- python: 3.5
Expand Down
2 changes: 1 addition & 1 deletiondoc/devel/contributing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,7 +151,7 @@ environment is set up properly::

.. note::

**Additional dependencies for testing**: pytest_ (version 3.1 or later),
**Additional dependencies for testing**: pytest_ (version 3.4 or later),
Ghostscript_, Inkscape_

.. seealso::
Expand Down
2 changes: 1 addition & 1 deletiondoc/devel/testing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ local FreeType build

The following software is required to run the tests:

- pytest_ (>=3.1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't this be 3.4?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

sorry, fixed

- pytest_ (>=3.4)
- Ghostscript_ (to render PDF files)
- Inkscape_ (to render SVG files)

Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/animation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -685,8 +685,7 @@ def _args(self):
'-vframes', str(self._frame_counter)] + self.output_args


# Base class of avconv information. AVConv has identical arguments to
# FFMpeg
# Base class of avconv information. AVConv has identical arguments to FFMpeg.
class AVConvBase(FFMpegBase):
'''Mixin class for avconv output.

Expand DownExpand Up@@ -1340,7 +1339,8 @@ def to_html5_video(self, embed_limit=None):
# Now open and base64 encode.
vid64 = base64.encodebytes(path.read_bytes())

if len(vid64) >= embed_limit:
vid_len = len(vid64)
if vid_len >= embed_limit:
_log.warning(
"Animation movie is %s bytes, exceeding the limit of %s. "
"If you're sure you want a large animation embedded, set "
Expand Down
97 changes: 71 additions & 26 deletionslib/matplotlib/tests/test_animation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import os
from pathlib import Path
import sys
import tempfile

Expand DownExpand Up@@ -38,29 +40,35 @@ def finish(self):
pass


def test_null_movie_writer():
# Test running an animation with NullMovieWriter.

fig = plt.figure()
def make_animation(**kwargs):
fig, ax = plt.subplots()
line, = ax.plot([])

def init():
pass

def animate(i):
pass
line.set_data([0, 1], [0, i])
return line,

return animation.FuncAnimation(fig, animate, **kwargs)


def test_null_movie_writer():
# Test running an animation with NullMovieWriter.

num_frames = 5
anim = make_animation(frames=num_frames)

filename = "unused.null"
dpi = 50
savefig_kwargs = dict(foo=0)

anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=num_frames)
writer = NullMovieWriter()

anim.save(filename, dpi=dpi, writer=writer,
savefig_kwargs=savefig_kwargs)

assert writer.fig ==fig
assert writer.fig ==plt.figure(1) # The figure used by make_animation.
assert writer.outfile == filename
assert writer.dpi == dpi
assert writer.args == ()
Expand DownExpand Up@@ -174,23 +182,8 @@ def animate(i):


def test_no_length_frames():
fig, ax = plt.subplots()
line, = ax.plot([], [])

def init():
line.set_data([], [])
return line,

def animate(i):
x = np.linspace(0, 10, 100)
y = np.sin(x + i)
line.set_data(x, y)
return line,

anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=iter(range(5)))
writer = NullMovieWriter()
anim.save('unused.null', writer=writer)
(make_animation(frames=iter(range(5)))
.save('unused.null', writer=NullMovieWriter()))


def test_movie_writer_registry():
Expand All@@ -215,3 +208,55 @@ def test_movie_writer_registry():
assert not animation.writers._dirty
assert animation.writers.is_available("ffmpeg")
mpl.rcParams['animation.ffmpeg_path'] = ffmpeg_path


@pytest.mark.skipif(
not animation.writers.is_available(mpl.rcParams["animation.writer"]),
reason="animation writer not installed")
@pytest.mark.parametrize("method_name", ["to_html5_video", "to_jshtml"])
def test_embed_limit(method_name, caplog):
with mpl.rc_context({"animation.embed_limit": 1e-6}): # ~1 byte.
getattr(make_animation(frames=1), method_name)()
assert len(caplog.records) == 1
record, = caplog.records
assert (record.name == "matplotlib.animation"
and record.levelname == "WARNING")


@pytest.mark.skipif(
not animation.writers.is_available(mpl.rcParams["animation.writer"]),
reason="animation writer not installed")
@pytest.mark.parametrize(
"method_name",
["to_html5_video",
pytest.mark.xfail("to_jshtml")]) # Needs to be fixed.
def test_cleanup_temporaries(method_name, tmpdir):
with tmpdir.as_cwd():
getattr(make_animation(frames=1), method_name)()
assert list(Path(str(tmpdir)).iterdir()) == []


# Currently, this fails with a ValueError after we try to communicate() twice
# with the Popen.
@pytest.mark.xfail
@pytest.mark.skipif(os.name != "posix", reason="requires a POSIX OS")
def test_failing_ffmpeg(tmpdir, monkeypatch):
"""
Test that we correctly raise an OSError when ffmpeg fails.

To do so, mock ffmpeg using a simple executable shell script that
succeeds when called with no arguments (so that it gets registered by
`isAvailable`), but fails otherwise, and add it to the $PATH.
"""
try:
with tmpdir.as_cwd():
monkeypatch.setenv("PATH", ".:" + os.environ["PATH"])
exe_path = Path(tmpdir, "ffmpeg")
exe_path.write_text("#!/bin/sh\n"
"[[ $@ -eq 0 ]]\n")
os.chmod(str(exe_path), 0o755)
animation.writers.reset_available_writers()
with pytest.raises(OSError):
make_animation().save("test.mpeg")
finally:
animation.writers.reset_available_writers()
2 changes: 1 addition & 1 deletionsetupext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -739,7 +739,7 @@ def get_namespace_packages(self):

class Tests(OptionalPackage):
name = "tests"
pytest_min_version = '3.1'
pytest_min_version = '3.4'
default_config = False

def check(self):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp