-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fixes issue #2556 #2558
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
fixes issue #2556 #2558
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b81e9f
fixes issue #2556
tacaswell fcaf629
pep8 fix
tacaswell 5e69629
renamed import
tacaswell c312cca
added test_quiver module
tacaswell 4cc466e
fixed memory leak in quiverkey
tacaswell e0972f0
pep8 + minor variable re-naming
tacaswell c07f674
removed un-needed weakref
tacaswell f92ee59
added missing self
tacaswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import print_function | ||
import os | ||
import tempfile | ||
import numpy as np | ||
import sys | ||
from matplotlib import pyplot as plt | ||
from matplotlib.testing.decorators import cleanup | ||
|
||
|
||
WRITER_OUTPUT = dict(ffmpeg='mp4', ffmpeg_file='mp4', | ||
mencoder='mp4', mencoder_file='mp4', | ||
avconv='mp4', avconv_file='mp4', | ||
imagemagick='gif', imagemagick_file='gif') | ||
|
||
|
||
@cleanup | ||
def test_quiver_memory_leak(): | ||
fig, ax = plt.subplots() | ||
|
||
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .04), | ||
np.arange(0, 2 * np.pi, .04)) | ||
U = np.cos(X) | ||
V = np.sin(Y) | ||
|
||
Q = ax.quiver(U, V) | ||
ttX = Q.X | ||
Q.remove() | ||
|
||
del Q | ||
|
||
assert sys.getrefcount(ttX) == 2 | ||
|
||
|
||
@cleanup | ||
def test_quiver_key_memory_leak(): | ||
fig, ax = plt.subplots() | ||
|
||
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .04), | ||
np.arange(0, 2 * np.pi, .04)) | ||
U = np.cos(X) | ||
V = np.sin(Y) | ||
|
||
Q = ax.quiver(U, V) | ||
|
||
qk = ax.quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', | ||
labelpos='W', | ||
fontproperties={'weight': 'bold'}) | ||
assert sys.getrefcount(qk) == 3 | ||
qk.remove() | ||
assert sys.getrefcount(qk) == 2 | ||
|
||
if __name__ == '__main__': | ||
import nose | ||
nose.runmodule() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use of weak ref looks fine (and I can't think of an alternative way)