8000 Close files in animation to silence some warning in the test suite on python3 by jenshnielsen · Pull Request #3215 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Close files in animation to silence some warning in the test suite on python3 #3215

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 4 commits into from
Jul 12, 2014
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 26 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ def isAvailable(cls):
running the commandline tool.
'''
try:
subprocess.Popen(cls.bin_path(),
p = subprocess.Popen(cls.bin_path(),
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p.communicate()
return True
except OSError:
return False
Expand Down Expand Up @@ -326,6 +327,30 @@ def _frame_sink(self):
# because it will no longer be referenced and will be gc-ed.
return open(fname, 'wb')

def grab_frame(self, **savefig_kwargs):
'''
Grab the image information from the figure and save as a movie frame.
All keyword arguments in savefig_kwargs are passed on to the 'savefig'
command that saves the figure.
'''
#Overloaded to explicitly close temp file.
verbose.report('MovieWriter.grab_frame: Grabbing frame.',
C0A8 level='debug')
try:
# Tell the figure to save its data to the sink, using the
# frame format and dpi.
myframesink = self._frame_sink()
self.fig.savefig(myframesink, format=self.frame_format,
dpi=self.dpi, **savefig_kwargs)
myframesink.close()

except RuntimeError:
out, err = self._proc.communicate()
verbose.report('MovieWriter -- Error '
'running proc:\n%s\n%s' % (out,
err), level='helpful')
raise

def finish(self):
# Call run here now that all frame grabbing is done. All temp files
# are available to be assembled.
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def animate(i):
raise KnownFailureTest("There can be errors in the numpy " +
"import stack, " +
"see issues #1891 and #2679")
finally:
F.close()


@cleanup
Expand Down
0