8000 Merge branch 'v1.5.x' into v2.0.x · matplotlib/matplotlib@527c85a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 527c85a

Browse files
committed
Merge branch 'v1.5.x' into v2.0.x
2 parents d561d2e + c7009ab commit 527c85a

File tree

6 files changed

+102
-30
lines changed

6 files changed

+102
-30
lines changed

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ Testing
2020

2121
After installation, you can launch the test suite::
2222

23-
python setup.py test
23+
python tests.py
2424

2525
Or from the python interpreter::
2626

2727
import matplotlib
2828
matplotlib.test()
2929

3030
Consider reading http://matplotlib.org/devel/coding_guide.html#testing for
31-
more information.
31+
more information. Note that the test suite requires nose and on python 2.7 mock
32+
which are not installed by default. Please install with pip or your package
33+
manager of choice.
3234

3335
Contact
3436
=======

doc/devel/release_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A guide for developers who are doing a matplotlib release.
1313
Testing
1414
=======
1515

16-
* Run all of the regression tests by running ``python setup.py test`` script
16+
* Run all of the regression tests by running ``python tests.py``
1717
at the root of the source tree.
1818

1919
* Run :file:`unit/memleak_hawaii3.py` and make sure there are no

doc/devel/testing.rst

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,40 @@ matplotlib source directory::
5252
Running the tests
5353
-----------------
5454

55-
Running the tests is simple. Make sure you have nose installed and run
56-
the setup script's ``test`` command::
55+
Running the tests is simple. Make sure you have nose installed and run::
5756

58-
python setup.py test
57+
python tests.py
5958

6059
in the root directory of the distribution. The script takes a set of
6160
commands, such as:
6261

6362
======================== ===========
64-
``--pep8-only`` pep8 checks
65-
``--omit-pep8`` Do not perform pep8 checks
66-
``--nocapture`` do not capture stdout (nosetests)
67-
``--nose-verbose`` be verbose (nosetests)
68-
``--processes`` number of processes (nosetests)
69-
``--process-timeout`` process timeout (nosetests)
70-
``--with-coverage`` with coverage
71-
``--detailed-error-msg`` detailed error message (nosetest)
72-
``--tests`` comma separated selection of tests (nosetest)
63+
``--pep8`` pep8 checks
64+
``--no-pep8`` Do not perform pep8 checks
65+
``--no-network`` Disable tests that require network access
7366
======================== ===========
7467

75-
Additionally it is possible to run only coding standard test or disable them:
68+
Additional arguments are passed on to nosetests. See the nose
69+
documentation for supported arguments. Some of the more important ones are given
70+
here:
7671

77-
=================== ===========
78-
``--pep8`` run only PEP8 checks
79-
``--no-pep8`` disable PEP8 checks
80-
=================== ===========
72+
============================= ===========
73+
``--verbose`` Be more verbose
74+
``--processes=NUM`` Run tests in parallel over NUM processes
75+
``--process-timeout=SECONDS`` Set timeout for results from test runner process
76+
``--nocapture`` Do not capture stdout
77+
============================= ===========
8178

8279
To run a single test from the command line, you can provide a
8380
dot-separated path to the module followed by the function separated by
8481
a colon, e.g., (this is assuming the test is installed)::
8582

86-
python setup.py test --tests=matplotlib.tests.test_simplification:test_clipping
83+
python tests.py matplotlib.tests.test_simplification:test_clipping
8784

8885
If you want to run the full test suite, but want to save wall time try
8986
running the tests in parallel::
9087

91-
python setup.py test --nocapture --nose-verbose --processes=5 --process-timeout=300
88+
python tests.py --nocapture --nose-verbose --processes=5 --process-timeout=300
9289

9390

9491
An alternative implementation that does not look at command line
@@ -100,9 +97,10 @@ matplotlib library function :func:`matplotlib.test`::
10097

10198
.. hint::
10299

103-
You might need to install nose for this::
100+
To run the tests you need to install nose and mock if using python 2.7::
104101

105102
pip install nose
103+
pip install mock
106104

107105

108106
.. _`nosetest arguments`: http://nose.readthedocs.org/en/latest/usage.html

lib/matplotlib/rcsetup.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
import operator
2323
import os
2424
import warnings
25+
try:
26+
import collections.abc as abc
27+
except ImportError:
28+
# python 2
29+
import collections as abc
2530
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
2631
from matplotlib.colors import is_color_like
2732

@@ -78,15 +83,19 @@ def f(s):
7883
return [scalar_validator(v.strip()) for v in s if v.strip()]
7984
else:
8085
raise
81-
elif type(s) in (list, tuple):
86+
# We should allow any generic sequence type, including generators,
87+
# Numpy ndarrays, and pandas data structures. However, unordered
88+
# sequences, such as sets, should be allowed but discouraged unless the
89+
# user desires pseudorandom behavior.
90+
elif isinstance(s, abc.Iterable) and not isinstance(s, abc.Mapping):
8291
# The condition on this list comprehension will preserve the
8392
# behavior of filtering out any empty strings (behavior was
8493
# from the original validate_stringlist()), while allowing
8594
# any non-string/text scalar values such as numbers and arrays.
8695
return [scalar_validator(v) for v in s
8796
if not isinstance(v, six.string_types) or v]
8897
else:
89-
msg = "'s' must be of type [ string | list | tuple ]"
98+
msg = "{0!r} must be of type: string or non-dictionary iterable.".format(s)
9099
raise ValueError(msg)
91100
f.__doc__ = scalar_validator.__doc__
92101
return f

lib/matplotlib/tests/test_cycles.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from matplotlib.testing.decorators import image_comparison
1+
from matplotlib.testing.decorators import image_comparison, cleanup
22
import matplotlib.pyplot as plt
33
import numpy as np
4+
from nose.tools import assert_raises
45

56
from cycler import cycler
67

@@ -42,6 +43,27 @@ def test_marker_cycle():
4243
ax.legend(loc='upper left')
4344

4445

46+
# Reuse the image from test_marker_cycle()
47+
@image_comparison(baseline_images=['marker_cycle'], remove_text=True,
48+
extensions=['png'])
49+
def test_marker_cycle_keywords():
50+
fig = plt.figure()
51+
ax = fig.add_subplot(111)
52+
# Test keyword arguments, numpy arrays, and generic iterators
53+
ax.set_prop_cycle(color=np.array(['r', 'g', 'y']),
54+
marker=iter(['.', '*', 'x']))
55+
xs = np.arange(10)
56+
ys = 0.25 * xs + 2
57+
ax.plot(xs, ys, label='red dot', lw=4, ms=16)
58+
ys = 0.45 * xs + 3
59+
ax.plot(xs, ys, label='green star', lw=4, ms=16)
60+
ys = 0.65 * xs + 4
61+
ax.plot(xs, ys, label='yellow x', lw=4, ms=16)
62+
ys = 0.85 * xs + 5
63+
ax.plot(xs, ys, label='red2 dot', lw=4, ms=16)
64+
ax.legend(loc='upper left')
65+
66+
4567
@image_comparison(baseline_images=['lineprop_cycle_basic'], remove_text=True,
4668
extensions=['png'])
4769
def test_linestylecycle_basic():
@@ -104,6 +126,40 @@ def test_fillcycle_ignore():
104126
ax.legend(loc='upper left')
105127

106128

129+
@cleanup
130+
def test_valid_input_forms():
131+
fig, ax = plt.subplots()
132+
# These should not raise an error.
133+
ax.set_prop_cycle(None)
134+
ax.set_prop_cycle(cycler('linewidth', [1, 2]))
135+
ax.set_prop_cycle('color', 'rgywkbcm')
136+
ax.set_prop_cycle('linewidth', (1, 2))
137+
ax.set_prop_cycle('linewidth', [1, 2])
138+
ax.set_prop_cycle('linewidth', iter([1, 2]))
139+
ax.set_prop_cycle('linewidth', np.array([1, 2]))
140+
ax.set_prop_cycle('color', np.array([[1, 0, 0],
141+
[0, 1, 0],
142+
[0, 0, 1]]))
143+
ax.set_prop_cycle(lw=[1, 2], color=['k', 'w'], ls=['-', '--'])
144+
ax.set_prop_cycle(lw=np.array([1, 2]),
145+
color=np.array(['k', 'w']),
146+
ls=np.array(['-', '--']))
147+
assert True
148+
149+
150+
@cleanup
151+
def test_invalid_input_forms():
152+
fig, ax = plt.subplots()
153+
assert_raises((TypeError, ValueError), ax.set_prop_cycle, 1)
154+
assert_raises((TypeError, ValueError), ax.set_prop_cycle, [1, 2])
155+
assert_raises((TypeError, ValueError), ax.set_prop_cycle, 'color', 'fish')
156+
assert_raises((TypeError, ValueError), ax.set_prop_cycle, 'linewidth', 1)
157+
assert_raises((TypeError, ValueError), ax.set_prop_cycle,
158+
'linewidth', {'1': 1, '2': 2})
159+
assert_raises((TypeError, ValueError), ax.set_prop_cycle,
160+
linewidth=1, color='r')
161+
162+
107163
if __name__ == '__main__':
108164
import nose
109165
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_rcparams.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,15 @@ def test_validators():
280280
('aardvark, ,', ['aardvark']),
281281
(['a', 'b'], ['a', 'b']),
282282
(('a', 'b'), ['a', 'b']),
283-
((1, 2), ['1', '2'])),
284-
'fail': ((dict(), ValueError),
285-
(1, ValueError),)
286-
},
283+
(iter(['a', 'b']), ['a', 'b']),
284+
(np.array(['a', 'b']), ['a', 'b']),
285+
((1, 2), ['1', '2']),
286+
(np.array([1, 2]), ['1', '2']),
287+
),
288+
'fail': ((dict(), ValueError),
289+
(1, ValueError),
290+
)
291+
},
287292
{'validator': validate_nseq_int(2),
288293
'success': ((_, [1, 2])
289294
for _ in ('1, 2', [1.5, 2.5], [1, 2],
@@ -353,6 +358,8 @@ def test_validators():
353358
(['', 'g', 'blue'], ['g', 'blue']),
354359
([np.array([1, 0, 0]), np.array([0, 1, 0])],
355360
np.array([[1, 0, 0], [0, 1, 0]])),
361+
(np.array([[1, 0, 0], [0, 1, 0]]),
362+
np.array([[1, 0, 0], [0, 1, 0]])),
356363
),
357364
'fail': (('fish', ValueError),
358365
),

0 commit comments

Comments
 (0)
0