X Tutup
Skip to content
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
5 changes: 0 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,18 +1474,13 @@ def _jupyter_nbextension_paths():


default_test_modules = [
'matplotlib.tests.test_agg',
'matplotlib.tests.test_arrow_patches',
'matplotlib.tests.test_artist',
'matplotlib.tests.test_backend_bases',
'matplotlib.tests.test_backend_pdf',
'matplotlib.tests.test_backend_pgf',
'matplotlib.tests.test_backend_ps',
'matplotlib.tests.test_backend_qt4',
'matplotlib.tests.test_backend_qt5',
'matplotlib.tests.test_backend_svg',
'matplotlib.tests.test_basic',
'matplotlib.tests.test_bbox_tight',
'matplotlib.tests.test_coding_standards',
'matplotlib.tests.test_dviread',
'matplotlib.tests.test_figure',
Expand Down
87 changes: 6 additions & 81 deletions lib/matplotlib/tests/test_agg.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import io
import os

from distutils.version import LooseVersion as V
from distutils.version import LooseVersion

import numpy as np
from numpy.testing import assert_array_almost_equal

from nose.tools import assert_raises
import pytest

from matplotlib.image import imread
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.testing import skip
from matplotlib.testing.decorators import (
cleanup, image_comparison, knownfailureif)
from matplotlib.testing.decorators import cleanup, image_comparison
from matplotlib import pyplot as plt
from matplotlib import collections
from matplotlib import path
Expand Down Expand Up @@ -73,71 +67,6 @@ def test_large_single_path_collection():
plt.savefig(buff)


def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
print(i, ' ', a2[1], end=' ')
return int(a2[1].split()[0])

# This test is disabled -- it uses old API. -ADS 2009-09-07
## def test_memleak():
## """Test agg backend for memory leaks."""
## from matplotlib.ft2font import FT2Font
## from numpy.random import rand
## from matplotlib.backend_bases import GraphicsContextBase
## from matplotlib.backends._backend_agg import RendererAgg

## fontname = '/usr/local/share/matplotlib/Vera.ttf'

## N = 200
## for i in range( N ):
## gc = GraphicsContextBase()
## gc.set_clip_rectangle( [20, 20, 20, 20] )
## o = RendererAgg( 400, 400, 72 )

## for j in range( 50 ):
## xs = [ 400*int(rand()) for k in range(8) ]
## ys = [ 400*int(rand()) for k in range(8) ]
## rgb = (1, 0, 0)
## pnts = zip( xs, ys )
## o.draw_polygon( gc, rgb, pnts )
## o.draw_polygon( gc, None, pnts )

## for j in range( 50 ):
## x = [ 400*int(rand()) for k in range(4) ]
## y = [ 400*int(rand()) for k in range(4) ]
## o.draw_lines( gc, x, y )

## for j in range( 50 ):
## args = [ 400*int(rand()) for k in range(4) ]
## rgb = (1, 0, 0)
## o.draw_rectangle( gc, rgb, *args )

## if 1: # add text
## font = FT2Font( fontname )
## font.clear()
## font.set_text( 'hi mom', 60 )
## font.set_size( 12, 72 )
## o.draw_text_image( font.get_image(), 30, 40, gc )

## fname = "agg_memleak_%05d.png"
## o.write_png( fname % i )
## val = report_memory( i )
## if i==1: start = val

## end = val
## avgMem = (end - start) / float(N)
## print 'Average memory consumed per loop: %1.4f\n' % (avgMem)

## #TODO: Verify the expected mem usage and approximate tolerance that
## # should be used
## #self.checkClose( 0.32, avgMem, absTol = 0.1 )

## # w/o text and w/o write_png: Average memory consumed per loop: 0.02
## # w/o text and w/ write_png : Average memory consumed per loop: 0.3400
## # w/ text and w/ write_png : Average memory consumed per loop: 0.32


@cleanup
def test_marker_with_nan():
# This creates a marker with nans in it, which was segfaulting the
Expand Down Expand Up @@ -251,7 +180,7 @@ def process_image(self, padded_src, dpi):
t2 = self.offset_filter.process_image(t1, dpi)
return t2

if V(np.__version__) < V('1.7.0'):
if LooseVersion(np.__version__) < LooseVersion('1.7.0'):
skip('Disabled on Numpy < 1.7.0')

fig = plt.figure()
Expand Down Expand Up @@ -297,9 +226,5 @@ def process_image(self, padded_src, dpi):
def test_too_large_image():
fig = plt.figure(figsize=(300, 1000))
buff = io.BytesIO()
assert_raises(ValueError, fig.savefig, buff)


if __name__ == "__main__":
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
with pytest.raises(ValueError):
fig.savefig(buff)
7 changes: 0 additions & 7 deletions lib/matplotlib/tests/test_arrow_patches.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import matplotlib.pyplot as plt
from matplotlib.testing.decorators import image_comparison
import matplotlib.patches as mpatches
Expand Down Expand Up @@ -121,8 +119,3 @@ def test_fancyarrow_dash():
color='k')
ax.add_patch(e)
ax.add_patch(e2)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
44 changes: 18 additions & 26 deletions lib/matplotlib/tests/test_artist.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import warnings
import six

import io
import warnings
from itertools import chain

import numpy as np

import matplotlib.pyplot as plt
Expand All @@ -14,11 +14,8 @@
import matplotlib.transforms as mtrans
import matplotlib.collections as mcollections
import matplotlib.artist as martist
import matplotlib as mpl
from matplotlib.testing.decorators import image_comparison, cleanup

from nose.tools import (assert_true, assert_false)


@cleanup
def test_patch_transform_of_none():
Expand Down Expand Up @@ -72,7 +69,7 @@ def test_collection_transform_of_none():
ax.set_xlim([1, 3])
ax.set_ylim([1, 3])

#draw an ellipse over data coord (2,2) by specifying device coords
# draw an ellipse over data coord (2,2) by specifying device coords
xy_data = (2, 2)
xy_pix = ax.transData.transform_point(xy_data)

Expand Down Expand Up @@ -184,28 +181,28 @@ def test_remove():
im = ax.imshow(np.arange(36).reshape(6, 6))
ln, = ax.plot(range(5))

assert_true(fig.stale)
assert_true(ax.stale)
assert fig.stale
assert ax.stale

fig.canvas.draw()
assert_false(fig.stale)
assert_false(ax.stale)
assert_false(ln.stale)
assert not fig.stale
assert not ax.stale
assert not ln.stale

assert_true(im in ax.mouseover_set)
assert_true(ln not in ax.mouseover_set)
assert_true(im.axes is ax)
assert im in ax.mouseover_set
assert ln not in ax.mouseover_set
assert im.axes is ax

im.remove()
ln.remove()

for art in [im, ln]:
assert_true(art.axes is None)
assert_true(art.figure is None)
assert art.axes is None
assert art.figure is None

assert_true(im not in ax.mouseover_set)
assert_true(fig.stale)
assert_true(ax.stale)
assert im not in ax.mouseover_set
assert fig.stale
assert ax.stale


@image_comparison(baseline_images=["default_edges"], remove_text=True,
Expand All @@ -221,8 +218,8 @@ def test_default_edges():
ax3.set_ylim((-1, 1))
pp1 = mpatches.PathPatch(
mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)],
[mpath.Path.MOVETO, mpath.Path.CURVE3,
mpath.Path.CURVE3, mpath.Path.CLOSEPOLY]),
[mpath.Path.MOVETO, mpath.Path.CURVE3,
mpath.Path.CURVE3, mpath.Path.CLOSEPOLY]),
fc="none", transform=ax4.transData)
ax4.add_patch(pp1)

Expand Down Expand Up @@ -254,8 +251,3 @@ def test_setp():
sio = io.StringIO()
plt.setp(lines1, 'zorder', file=sio)
assert sio.getvalue() == ' zorder: any number \n'


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
13 changes: 2 additions & 11 deletions lib/matplotlib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import six
import sys

import warnings

from nose.tools import assert_equal

from ..testing.decorators import knownfailureif, skipif


Expand All @@ -19,13 +15,13 @@ def setup_module():


def test_simple():
assert_equal(1 + 1, 2)
assert 1 + 1 == 2


@knownfailureif(True)
def test_simple_knownfail():
# Test the known fail mechanism.
assert_equal(1 + 1, 3)
assert 1 + 1 == 3


@skipif(True, reason="skipif decorator test with bool condition passed")
Expand Down Expand Up @@ -91,8 +87,3 @@ def test_override_builtins():
overridden = True

assert not overridden


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
24 changes: 8 additions & 16 deletions lib/matplotlib/tests/test_bbox_tight.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import xrange

import numpy as np

from matplotlib import rcParams
from matplotlib.testing.decorators import image_comparison
import matplotlib.pyplot as plt
import matplotlib.path as mpath
Expand All @@ -18,11 +14,11 @@
savefig_kwarg=dict(bbox_inches='tight'))
def test_bbox_inches_tight():
#: Test that a figure saved using bbox_inches='tight' is clipped correctly
data = [[ 66386, 174296, 75131, 577908, 32015],
[ 58230, 381139, 78045, 99308, 160454],
[ 89135, 80552, 152558, 497981, 603535],
[ 78415, 81858, 150656, 193263, 69638],
[139361, 331509, 343164, 781380, 52269]]
data = [[66386, 174296, 75131, 577908, 32015],
[58230, 381139, 78045, 99308, 160454],
[89135, 80552, 152558, 497981, 603535],
[78415, 81858, 150656, 193263, 69638],
[139361, 331509, 343164, 781380, 52269]]

colLabels = rowLabels = [''] * 5

Expand All @@ -33,7 +29,7 @@ def test_bbox_inches_tight():
yoff = np.array([0.0] * len(colLabels))
# the bottom values for stacked bar chart
fig, ax = plt.subplots(1, 1)
for row in xrange(rows):
for row in range(rows):
ax.bar(ind, data[row], width, bottom=yoff, color='b')
yoff = yoff + data[row]
cellText.append([''])
Expand All @@ -49,7 +45,7 @@ def test_bbox_inches_tight():
@image_comparison(baseline_images=['bbox_inches_tight_suptile_legend'],
remove_text=False, savefig_kwarg={'bbox_inches': 'tight'})
def test_bbox_inches_tight_suptile_legend():
plt.plot(list(xrange(10)), label='a straight line')
plt.plot(np.arange(10), label='a straight line')
plt.legend(bbox_to_anchor=(0.9, 1), loc=2, )
plt.title('Axis title')
plt.suptitle('Figure title')
Expand All @@ -70,7 +66,7 @@ def y_formatter(y, pos):
def test_bbox_inches_tight_clipping():
# tests bbox clipping on scatter points, and path clipping on a patch
# to generate an appropriately tight bbox
plt.scatter(list(xrange(10)), list(xrange(10)))
plt.scatter(np.arange(10), np.arange(10))
ax = plt.gca()
ax.set_xlim([0, 5])
ax.set_ylim([0, 5])
Expand All @@ -93,7 +89,3 @@ def test_bbox_inches_tight_raster():
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1.0, 2.0], rasterized=True)

if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
1 change: 0 additions & 1 deletion lib/matplotlib/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def test_pep8_conformance_installed_files():
'testing/jpl_units/__init__.py',
'tri/triinterpolate.py',
'tests/test_axes.py',
'tests/test_bbox_tight.py',
'tests/test_image.py',
'tests/test_lines.py',
'tests/test_mathtext.py',
Expand Down
X Tutup