Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2558 from tacaswell/quiver_memory_leak
fixes issue #2556
- Loading branch information
Showing
3 changed files
with
115 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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() |