Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54cb638

Browse files
authored
Merge branch 'master' into lru-cache
2 parents 13225b3 + f06ad39 commit 54cb638

File tree

19 files changed

+122
-115
lines changed

19 files changed

+122
-115
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ matrix:
8585
- python: "nightly"
8686
env: PRE=--pre
8787
- os: osx
88-
osx_image: xcode7.3
8988
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
9089
env: MOCK=mock
9190
only: master
@@ -109,8 +108,8 @@ before_install:
109108
export PATH=$PATH:/tmp/λ
110109
export PATH=/usr/lib/ccache:$PATH
111110
else
112-
brew update
113-
brew install python3 libpng ffmpeg imagemagick mplayer ccache
111+
ci/travis/silence brew update
112+
brew install python3 ffmpeg imagemagick mplayer ccache
114113
# make 'python' mean 'python3'
115114
ln -sf /usr/local/bin/python3 /usr/local/bin/python
116115
hash -r

ci/travis/silence

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Run a command, hiding its standard output and error if its exit
4+
# status is zero.
5+
6+
stdout=$(mktemp -t stdout) || exit 1
7+
stderr=$(mktemp -t stderr) || exit 1
8+
"$@" >$stdout 2>$stderr
9+
code=$?
10+
if [[ $code != 0 ]]; then
11+
cat $stdout
12+
cat $stderr >&2
13+
exit $code
14+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Deprecations
2+
````````````
3+
``cbook.is_numlike`` is deprecated. Use ``isinstance(..., numbers.Number)``
4+
instead.

doc/users/whats_new.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,14 @@ New style colorblind-friendly color cycle
161161

162162
A new style defining a color cycle has been added,
163163
tableau-colorblind10, to provide another option for
164-
colorblind-friendly plots.
164+
colorblind-friendly plots. A demonstration of this new
165+
style can be found in the reference_ of style sheets. To
166+
load this color cycle in place of the default one::
167+
168+
import matplotlib.pyplot as plt
169+
plt.style.use('tableau-colorblind10')
170+
171+
.. _reference: https://matplotlib.org/gallery/style_sheets/style_sheets_reference.html
165172

166173

167174
Support for numpy.datetime64

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import itertools
99
import logging
1010
import math
11+
from numbers import Number
1112
import warnings
1213

1314
import numpy as np
@@ -6526,7 +6527,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65266527
m[:] = (m / db) / tops[-1].sum()
65276528
if cumulative:
65286529
slc = slice(None)
6529-
if cbook.is_numlike(cumulative) and cumulative < 0:
6530+
if isinstance(cumulative, Number) and cumulative < 0:
65306531
slc = slice(None, None, -1)
65316532

65326533
if density:

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,11 +2320,14 @@ def margins(self, *args, **kw):
23202320
23212321
All three forms above set the xmargin and ymargin parameters.
23222322
All keyword parameters are optional. A single argument
2323-
specifies both xmargin and ymargin. The *tight* parameter
2324-
is passed to :meth:`autoscale_view`, which is executed after
2325-
a margin is changed; the default here is *True*, on the
2326-
assumption that when margins are specified, no additional
2327-
padding to match tick marks is usually desired. Setting
2323+
specifies both xmargin and ymargin. The padding added to the end of
2324+
each interval is *margin* times the data interval. The *margin* must
2325+
be a float in the range [0, 1].
2326+
2327+
The *tight* parameter is passed to :meth:`autoscale_view`
2328+
, which is executed after a margin is changed; the default here is
2329+
*True*, on the assumption that when margins are specified, no
2330+
additional padding to match tick marks is usually desired. Setting
23282331
*tight* to *None* will preserve the previous setting.
23292332
23302333
Specifying any margin changes only the autoscaling; for example,

lib/matplotlib/backends/backend_pdf.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
A PDF matplotlib backend
55
Author: Jouni K Seppänen <[email protected]>
66
"""
7-
from __future__ import (absolute_import, division, print_function,
8-
unicode_literals)
9-
10-
import six
11-
from six import unichr
127

138
import codecs
149
import collections
@@ -160,11 +155,11 @@ def pdfRepr(obj):
160155
return [b'false', b'true'][obj]
161156

162157
# Integers are written as such.
163-
elif isinstance(obj, (six.integer_types, np.integer)):
158+
elif isinstance(obj, (int, np.integer)):
164159
return ("%d" % obj).encode('ascii')
165160

166161
# Unicode strings are encoded in UTF-16BE with byte-order mark.
167-
elif isinstance(obj, six.text_type):
162+
elif isinstance(obj, str):
168163
try:
169164
# But maybe it's really ASCII?
170165
s = obj.encode('ASCII')
@@ -269,7 +264,7 @@ def __repr__(self):
269264
return "<Name %s>" % self.name
270265

271266
def __str__(self):
272-
return '/' + six.text_type(self.name)
267+
return '/' + str(self.name)
273268

274269
def __eq__(self, other):
275270
return isinstance(other, Name) and self.name == other.name
@@ -325,7 +320,7 @@ def pdfRepr(self):
325320
grestore=b'Q', textpos=b'Td', selectfont=b'Tf', textmatrix=b'Tm',
326321
show=b'Tj', showkern=b'TJ', setlinewidth=b'w', clip=b'W', shading=b'sh')
327322

328-
Op = Bunch(**{name: Operator(value) for name, value in six.iteritems(_pdfops)})
323+
Op = Bunch(**{name: Operator(value) for name, value in _pdfops.items()})
329324

330325

331326
def _paint_path(fill, stroke):
@@ -576,14 +571,14 @@ def finalize(self):
576571
self.writeFonts()
577572
self.writeObject(
578573
self.alphaStateObject,
579-
{val[0]: val[1] for val in six.itervalues(self.alphaStates)})
574+
{val[0]: val[1] for val in self.alphaStates.values()})
580575
self.writeHatches()
581576
self.writeGouraudTriangles()
582577
xobjects = {
583-
name: ob for image, name, ob in six.itervalues(self._images)}
584-
for tup in six.itervalues(self.markers):
578+
name: ob for image, name, ob in self._images.values()}
579+
for tup in self.markers.values():
585580
xobjects[tup[0]] = tup[1]
586-
for name, value in six.iteritems(self.multi_byte_charprocs):
581+
for name, value in self.multi_byte_charprocs.items():
587582
xobjects[name] = value
588583
for name, path, trans, ob, join, cap, padding, filled, stroked \
589584
in self.paths:
@@ -639,7 +634,7 @@ def fontName(self, fontprop):
639634
as the filename of the font.
640635
"""
641636

642-
if isinstance(fontprop, six.string_types):
637+
if isinstance(fontprop, str):
643638
filename = fontprop
644639
elif rcParams['pdf.use14corefonts']:
645640
filename = findfont(
@@ -1078,7 +1073,7 @@ def embedTTFType42(font, characters, descriptor):
10781073
flags=LOAD_NO_SCALE | LOAD_NO_HINTING)
10791074
widths.append((ccode, cvt(glyph.horiAdvance)))
10801075
if ccode < 65536:
1081-
cid_to_gid_map[ccode] = unichr(gind)
1076+
cid_to_gid_map[ccode] = chr(gind)
10821077
max_ccode = max(ccode, max_ccode)
10831078
widths.sort()
10841079
cid_to_gid_map = cid_to_gid_map[:max_ccode + 1]
@@ -1232,7 +1227,7 @@ def hatchPattern(self, hatch_style):
12321227
def writeHatches(self):
12331228
hatchDict = dict()
12341229
sidelen = 72.0
1235-
for hatch_style, name in six.iteritems(self.hatchPatterns):
1230+
for hatch_style, name in self.hatchPatterns.items():
12361231
ob = self.reserveObject('hatch pattern')
12371232
hatchDict[name] = ob
12381233
res = {'Procsets':
@@ -1410,7 +1405,7 @@ def _writeImg(self, data, height, width, grayscale, id, smask=None):
14101405
self.endStream()
14111406

14121407
def writeImages(self):
1413-
for img, name, ob in six.itervalues(self._images):
1408+
for img, name, ob in self._images.values():
14141409
height, width, data, adata = self._unpack(img)
14151410
if adata is not None:
14161411
smaskObject = self.reserveObject("smask")
@@ -1451,7 +1446,7 @@ def markerObject(self, path, trans, fill, stroke, lw, joinstyle,
14511446

14521447
def writeMarkers(self):
14531448
for ((pathops, fill, stroke, joinstyle, capstyle),
1454-
(name, ob, bbox, lw)) in six.iteritems(self.markers):
1449+
(name, ob, bbox, lw)) in self.markers.items():
14551450
bbox = bbox.padded(lw * 0.5)
14561451
self.beginStream(
14571452
ob.id, None,
@@ -1557,7 +1552,7 @@ def writeInfoDict(self):
15571552
"""Write out the info dictionary, checking it for good form"""
15581553

15591554
def is_string_like(x):
1560-
return isinstance(x, six.string_types)
1555+
return isinstance(x, str)
15611556

15621557
def is_date(x):
15631558
return isinstance(x, datetime)
@@ -1643,7 +1638,7 @@ def check_gc(self, gc, fillcolor=None):
16431638
def track_characters(self, font, s):
16441639
"""Keeps track of which characters are required from
16451640
each font."""
1646-
if isinstance(font, six.string_types):
1641+
if isinstance(font, str):
16471642
fname = font
16481643
else:
16491644
fname = font.fname
@@ -1653,7 +1648,7 @@ def track_characters(self, font, s):
16531648
used_characters[1].update([ord(x) for x in s])
16541649

16551650
def merge_used_characters(self, other):
1656-
for stat_key, (realpath, charset) in six.iteritems(other):
1651+
for stat_key, (realpath, charset) in other.items():
16571652
used_characters = self.file.used_characters.setdefault(
16581653
stat_key, (realpath, set()))
16591654
used_characters[1].update(charset)
@@ -1881,7 +1876,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
18811876
self.file.output(self.file.fontName(fontname), fontsize,
18821877
Op.selectfont)
18831878
prev_font = fontname, fontsize
1884-
self.file.output(self.encode_string(unichr(num), fonttype),
1879+
self.file.output(self.encode_string(chr(num), fonttype),
18851880
Op.show)
18861881
self.file.output(Op.end_text)
18871882

@@ -1935,10 +1930,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
19351930
pdfname = self.file.dviFontName(dvifont)
19361931
seq += [['font', pdfname, dvifont.size]]
19371932
oldfont = dvifont
1938-
# We need to convert the glyph numbers to bytes, and the easiest
1939-
# way to do this on both Python 2 and 3 is .encode('latin-1')
1940-
seq += [['text', x1, y1,
1941-
[six.unichr(glyph).encode('latin-1')], x1+width]]
1933+
seq += [['text', x1, y1, [bytes([glyph])], x1+width]]
19421934

19431935
# Find consecutive text strings with constant y coordinate and
19441936
# combine into a sequence of strings and kerns, or just one
@@ -2046,7 +2038,7 @@ def check_simple_method(s):
20462038
if fonttype == 3 and not isinstance(s, bytes) and len(s) != 0:
20472039
# Break the string into chunks where each chunk is either
20482040
# a string of chars <= 255, or a single character > 255.
2049-
s = six.text_type(s)
2041+
s = str(s)
20502042
for c in s:
20512043
if ord(c) <= 255:
20522044
char_type = 1

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ def is_scalar(obj):
581581
return not isinstance(obj, six.string_types) and not iterable(obj)
582582

583583

584+
@deprecated('3.0', 'isinstance(..., numbers.Number)')
584585
def is_numlike(obj):
585586
"""return true if *obj* looks like a number"""
586587
return isinstance(obj, (numbers.Number, np.number))

lib/matplotlib/collections.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
import six
1717
from six.moves import zip
18+
19+
from numbers import Number
1820
try:
1921
from math import gcd
2022
except ImportError:
@@ -370,7 +372,7 @@ def contains(self, mouseevent):
370372

371373
pickradius = (
372374
float(self._picker)
373-
if cbook.is_numlike(self._picker) and
375+
if isinstance(self._picker, Number) and
374376
self._picker is not True # the bool, not just nonzero or 1
375377
else self._pickradius)
376378

0 commit comments

Comments
 (0)