8000 Merge remote-tracking branch 'upstream/v1.3.x' · matplotlib/matplotlib@88c49a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 88c49a9

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
2 parents 7af7678 + 42165c8 commit 88c49a9

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

doc/api/api_changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ Code changes
263263
* The :func:`matplotlib.cbook.check_output` function has been moved to
264264
:func:`matplotlib.compat.subprocess`.
265265

266+
* The method :meth:`~matplotlib.axes.Axes.hist` now always returns bin
267+
occupancies as an array of type `float`. Previously, it was sometimes
268+
an array of type `int`, depending on the call.
269+
266270
Configuration and rcParams
267271
--------------------------
268272

lib/matplotlib/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def setup():
1818

1919
try:
2020
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
21-
except:
21+
except locale.Error:
2222
try:
2323
locale.setlocale(locale.LC_ALL, str('English_United States.1252'))
24-
except:
24+
except locale.Error:
2525
warnings.warn(
2626
"Could not set locale to English/United States. "
2727
"Some date-related tests may fail")

lib/matplotlib/tests/test_coding_standards.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
except ImportError:
1515
HAS_PEP8 = False
1616
else:
17-
HAS_PEP8 = True
17+
HAS_PEP8 = pep8.__version__ > '1.4.5'
1818

1919
import matplotlib
2020

@@ -127,17 +127,21 @@ class StandardReportWithExclusions(pep8.StandardReport):
127127
'*/matplotlib/projections/geo.py',
128128
'*/matplotlib/projections/polar.py']
129129

130+
#: A class attribute to store the lines of failing tests.
131+
_global_deferred_print = []
132+
130133
#: A class attribute to store patterns which have seen exceptions.
131134
matched_exclusions = set()
132135

133136
def get_file_results(self):
134-
# If the file had no errors, return self.file_errors (which will be 0)
137+
# If the file had no errors, return self.file_errors
138+
# (which will be 0).
135139
if not self._deferred_print:
136140
return self.file_errors
137141

138-
# Iterate over all of the patterns, to find a possible exclusion. If we
139-
# the filename is to be excluded, go ahead and remove the counts that
140-
# self.error added.
142+
# Iterate over all of the patterns, to find a possible exclusion.
143+
# If the filename is to be excluded, go ahead and remove the
144+
# counts that self.error added.
141145
for pattern in self.expected_bad_files:
142146
if fnmatch(self.filename, pattern):
143147
self.matched_exclusions.add(pattern)
@@ -151,12 +155,20 @@ def get_file_results(self):
151155
self.total_errors -= 1
152156
return self.file_errors
153157

154-
# Otherwise call the superclass' method to print the bad results.
155-
return super(StandardReportWithExclusions,
156-
self).get_file_results()
158+
# mirror the content of StandardReport, only storing the output to
159+
# file rather than printing. This could be a feature request for
160+
# the PEP8 tool.
161+
self._deferred_print.sort()
162+
for line_number, offset, code, text, _ in self._deferred_print:
163+
self._global_deferred_print.append(
164+
self._fmt % {'path': self.filename,
165+
'row': self.line_offset + line_number,
166+
'col': offset + 1, 'code': code,
167+
'text': text})
168+
return self.file_errors
157169

158170

159-
def _test_pep8_conformance():
171+
def test_pep8_conformance():
160172
# Tests the matplotlib codebase against the "pep8" tool.
161173
#
162174
# Users can add their own excluded files (should files exist in the
@@ -172,11 +184,12 @@ def _test_pep8_conformance():
172184
# "reporter=pep8.FileReport" to the StyleGuide constructor.
173185
pep8style = pep8.StyleGuide(quiet=False,
174186
reporter=StandardReportWithExclusions)
187+
reporter = pep8style.options.reporter
175188

176189
# Extend the number of PEP8 guidelines which are not checked.
177-
pep8style.options.ignore = pep8style.options.ignore + ('E121', 'E122',
178-
'E123', 'E124', 'E125', 'E126', 'E127',
179-
'E128')
190+
pep8style.options.ignore = (pep8style.options.ignore +
191+
('E121', 'E122', 'E123', 'E124', 'E125',
192+
'E126', 'E127', 'E128'))
180193

181194
# Support for egg shared object wrappers, which are not PEP8 compliant,
182195
# nor part of the matplotlib repository.
@@ -205,10 +218,15 @@ def _test_pep8_conformance():
205218
pep8style.options.exclude.extend(extra_exclude)
206219

207220
result = pep8style.check_files([os.path.dirname(matplotlib.__file__)])
208-
assert_equal(result.total_errors, 0, "Found code syntax "
221+
if reporter is StandardReportWithExclusions:
222+
assert_equal(result.total_errors, 0,
223+
("Found code syntax errors (and warnings):\n"
224+
"{0}".format(
225+
'\n'.join(reporter._global_deferred_print))))
226+
else:
227+
assert_equal(result.total_errors, 0, "Found code syntax "
209228
"errors (and warnings).")
210229

211-
reporter = pep8style.options.reporter
212230
# If we've been using the exclusions reporter, check that we didn't
213231
# exclude files unnecessarily.
214232
if reporter is StandardReportWithExclusions:

lib/matplotlib/tests/test_table.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
extensions=['png'],
1212
remove_text=True)
1313
def test_zorder():
14-
data = [[ 66386, 174296,],
15-
[ 58230, 381139,]]
14+
data = [[66386, 174296],
15+
[58230, 381139]]
1616

1717
colLabels = ('Freeze', 'Wind')
1818
rowLabels = ['%d year' % x for x in (100, 50)]
1919

20-
2120
cellText = []
2221
yoff = np.array([0.0] * len(colLabels))
2322
for row in reversed(data):

0 commit comments

Comments
 (0)
0