8000 Import JSAnimation into the animation module. (Fixes #4703) by dopplershift · Pull Request #4821 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Import JSAnimation into the animation module. (Fixes #4703) #4821

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 1, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Some cleanups to HTMLWriter.
  • Loading branch information
dopplershift committed Sep 1, 2017
commit ffb2ccd5d69e1f68bdc383c42a05ee164b6f57c7
10 changes: 4 additions & 6 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,10 +928,9 @@ def __init__(self, fps=30, codec=None, bitrate=None, extra_args=None,

if self.default_mode not in ['loop', 'once', 'reflect']:
self.default_mode = 'loop'
import warnings
warnings.warn("unrecognized default_mode: using 'loop'")

self._saved_frames = list()
self._saved_frames = []
self._total_bytes = 0
self._hit_limit = False
super(HTMLWriter, self).__init__(fps, codec, bitrate,
Expand Down Expand Up @@ -962,8 +961,7 @@ def grab_frame(self, **savefig_kwargs):
f = InMemory()
self.fig.savefig(f, format=self.frame_format,
dpi=self.dpi, **savefig_kwargs)
f.seek(0)
imgdata64 = encodebytes(f.read()).decode('ascii')
imgdata64 = encodebytes(f.getvalue()).decode('ascii')
self._total_bytes += len(imgdata64)
if self._total_bytes >= self._bytes_limit:
warnings.warn("Animation size has reached {0._total_bytes} "
Expand Down Expand Up @@ -1004,7 +1002,7 @@ def communicate(self):
reflect_checked='')
mode_dict[self.default_mode + '_checked'] = 'checked'

interval = int(1000. / self.fps)
interval = 1000 // self.fps

with open(self.outfile, 'w') as of:
of.write(JS_INCLUDE)
Expand Down Expand Up @@ -1452,7 +1450,7 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None):
"""Generate HTML representation of the animation"""
if fps is None and hasattr(self, '_interval'):
# Convert interval in ms to frames per second
fps = 1000. / self._interval
fps = 1000 / self._interval

# If we're not given a default mode, choose one base on the value of
# the repeat attribute
Expand Down
0