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

Skip to content

Commit d5fb921

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: lib/matplotlib/cbook.py - keep 2.x version (bit more explicit) setupext.py - do not mess with windows changes
2 parents f19241d + 04dce81 commit d5fb921

File tree

10 files changed

+131
-47
lines changed

10 files changed

+131
-47
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ cache:
44
directories:
55
- $HOME/.ccache
66
- $HOME/.cache/pip
7+
- $HOME/.cache/matplotlib
78

89
addons:
910
apt:
@@ -133,6 +134,8 @@ script:
133134
pip install linkchecker
134135
linkchecker build/html/index.html
135136
fi
137+
- rm -rf $HOME/.cache/matplotlib/tex.cache
138+
- rm -rf $HOME/.cache/matplotlib/test_cache
136139

137140
after_failure:
138141
- |

doc/devel/testing.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ matplotlib source directory::
4949
[test]
5050
local_freetype = True
5151

52+
or by setting the ``MPLLOCALFREETYPE`` environmental variable to any true
53+
value.
54+
5255
Running the tests
5356
-----------------
5457

@@ -65,7 +68,7 @@ commands, such as:
6568
``--no-network`` Disable tests that require network access
6669
======================== ===========
6770

68-
Additional arguments are passed on to nosetests. See the nose
71+
Additional arguments are passed on to nosetests. See the nose
6972
documentation for supported arguments. Some of the more important ones are given
7073
here:
7174

examples/pylab_examples/polar_legend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# force square figure and square axes looks better for polar, IMO
1212
fig = figure(figsize=(8, 8))
13-
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], projection='polar', facecolor='#d5de9c')
13+
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8],
14+
projection='polar', facecolor='#d5de9c')
1415

1516
r = np.arange(0, 3.0, 0.01)
1617
theta = 2*np.pi*r

examples/widgets/radio_buttons.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
plt.subplots_adjust(left=0.3)
1313

1414
axcolor = 'lightgoldenrodyellow'
15-
rax = plt.axes([0.05, 0.7, 0.15, 0.15], axisbg=axcolor)
15+
rax = plt.axes([0.05, 0.7, 0.15, 0.15], facecolor=axcolor)
1616
radio = RadioButtons(rax, ('2 Hz', '4 Hz', '8 Hz'))
1717

1818

@@ -23,7 +23,7 @@ def hzfunc(label):
2323
plt.draw()
2424
radio.on_clicked(hzfunc)
2525

26-
rax = plt.axes([0.05, 0.4, 0.15, 0.15], axisbg=axcolor)
26+
rax = plt.axes([0.05, 0.4, 0.15, 0.15], facecolor=axcolor)
2727
radio2 = RadioButtons(rax, ('red', 'blue', 'green'))
2828

2929

@@ -32,7 +32,7 @@ def colorfunc(label):
3232
plt.draw()
3333
radio2.on_clicked(colorfunc)
3434

35-
rax = plt.axes([0.05, 0.1, 0.15, 0.15], axisbg=axcolor)
35+
rax = plt.axes([0.05, 0.1, 0.15, 0.15], facecolor=axcolor)
3636
radio3 = RadioButtons(rax, ('-', '--', '-.', 'steps', ':'))
3737

3838

lib/matplotlib/artist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
# python trick. The answer is that I need to be able to manipulate
3131
# the docstring, and there is no clever way to do that in python 2.2,
3232
# as far as I can see - see
33-
# http://groups.google.com/groups?hl=en&lr=&threadm=mailman.5090.1098044946.5135.python-list%40python.org&rnum=1&prev=/groups%3Fq%3D__doc__%2Bauthor%253Ajdhunter%2540ace.bsd.uchicago.edu%26hl%3Den%26btnG%3DGoogle%2BSearch
33+
#
34+
# https://mail.python.org/pipermail/python-list/2004-October/242925.html
3435

3536

3637
def allow_rasterization(draw):

lib/matplotlib/axes/_base.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,14 @@ def __str__(self):
413413
return "Axes(%g,%g;%gx%g)" % tuple(self._position.bounds)
414414

415415
def __init__(self, fig, rect,
416-
axisbg=None, # defaults to rc axes.facecolor
416+
facecolor=None, # defaults to rc axes.facecolor
417417
frameon=True,
418418
sharex=None, # use Axes instance's xaxis info
419419
sharey=None, # use Axes instance's yaxis info
420420
label='',
421421
xscale=None,
422422
yscale=None,
423+
axisbg=None, # This will be removed eventually
423424
**kwargs
424425
):
425426
"""
@@ -508,13 +509,17 @@ def __init__(self, fig, rect,
508509

509510
# this call may differ for non-sep axes, e.g., polar
510511
self._init_axis()
511-
512-
if axisbg is None:
513-
axisbg = rcParams['axes.facecolor']
514-
else:
512+
if axisbg is not None and facecolor is not None:
513+
raise TypeError('Both axisbg and facecolor are not None. '
514+
'These keywords are aliases, only one may be '
515+
'provided.')
516+
if axisbg is not None:
515517
cbook.warn_deprecated(
516518
'2.0', name='axisbg', alternative='facecolor')
517-
self._axisbg = axisbg
519+
facecolor = axisbg
520+
if facecolor is None:
521+
facecolor = rcParams['axes.facecolor']
522+
self._facecolor = facecolor
518523
self._frameon = frameon
519524
self._axisbelow = rcParams['axes.axisbelow']
520525

@@ -1053,7 +1058,7 @@ def cla(self):
10531058
# setting the edgecolor to None
10541059
self.patch = self.axesPatch = self._gen_axes_patch()
10551060
self.patch.set_figure(self.figure)
1056-
self.patch.set_facecolor(self._axisbg)
1061+
self.patch.set_facecolor(self._facecolor)
10571062
self.patch.set_edgecolor('None')
10581063
self.patch.set_linewidth(0)
10591064
self.patch.set_transform(self.transAxes)
@@ -1083,6 +1088,7 @@ def get_facecolor(self):
10831088
get_fc = get_facecolor
10841089

10851090
def set_facecolor(self, color):
1091+
self._facecolor = color
10861092
return self.patch.set_facecolor(color)
10871093
set_fc = set_facecolor
10881094

@@ -2711,7 +2717,7 @@ def set_axis_on(self):
27112717
@cbook.deprecated('2.0', alternative='get_facecolor')
27122718
def get_axis_bgcolor(self):
27132719
"""Return the axis background color"""
2714-
return self._axisbg
2720+
return self.get_facecolor()
27152721

27162722
@cbook.deprecated('2.0', alternative='set_facecolor')
27172723
def set_axis_bgcolor(self, color):
@@ -2721,12 +2727,7 @@ def set_axis_bgcolor(self, color):
27212727
ACCEPTS: any matplotlib color - see
27222728
:func:`~matplotlib.pyplot.colors`
27232729
"""
2724-
warnings.warn(
2725-
"set_axis_bgcolor is deprecated. Use set_facecolor instead.",
2726-
cbook.mplDeprecation)
2727-
self._axisbg = color
2728-
self.patch.set_facecolor(color)
2729-
self.stale = True
2730+
return self.set_facecolor(color)
27302731
# data limits, ticks, tick labels, and formatting
27312732

27322733
def invert_xaxis(self):

lib/matplotlib/cbook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,13 +2515,13 @@ def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
25152515

25162516
fail_keys = [k for k in required if k not in ret]
25172517
if fail_keys:
2518-
raise TypeError("The required keys {!r} "
2519-
"are not in kwargs".format(fail_keys))
2518+
raise TypeError("The required keys {keys!r} "
2519+
"are not in kwargs".format(keys=fail_keys))
25202520

25212521
fail_keys = [k for k in forbidden if k in ret]
25222522
if fail_keys:
2523-
raise TypeError("The forbidden keys {!r} "
2524-
"are in kwargs".format(fail_keys))
2523+
raise TypeError("The forbidden keys {keys!r} "
2524+
"are in kwargs".format(keys=fail_keys))
25252525

25262526
if allowed is not None:
25272527
allowed_set = set(required) | set(allowed)

lib/matplotlib/pyplot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ def xkcd(scale=1, length=100, randomness=2):
403403
rcParams['grid.linewidth'] = 0.0
404404
rcParams['axes.grid'] = False
405405
rcParams['axes.unicode_minus'] = False
406-
rcParams['axes.prop_cycle'] = cycler('color', ['b', 'r', 'c', 'm'])
407406
rcParams['axes.edgecolor'] = 'black'
408407
rcParams['xtick.major.size'] = 8
409408
rcParams['xtick.major.width'] = 3

matplotlibrc.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# Colors: for the color values below, you can either use - a
2525
# matplotlib color string, such as r, k, or b - an rgb tuple, such as
26-
# (1.0, 0.5, 0.0) - a hex string, such as ff00ff or #ff00ff - a scalar
26+
# (1.0, 0.5, 0.0) - a hex string, such as ff00ff - a scalar
2727
# grayscale intensity such as 0.75 - a legal html color name, e.g., red,
2828
# blue, darkslategray
2929

@@ -105,7 +105,7 @@ backend : $TEMPLATE_BACKEND
105105
#patch.linewidth : None # edge width in points.
106106
# If None, use axes.linewidth when patch
107107
# is not filled.
108-
#patch.facecolor : #1f77b4
108+
#patch.facecolor : 1f77b4
109109
#patch.edgecolor : black
110110
#patch.antialiased : True # render patches in antialiased (no jaggies)
111111

@@ -321,9 +321,9 @@ backend : $TEMPLATE_BACKEND
321321
# rather than hyphen. See
322322
# http://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes
323323
#axes.prop_cycle : cycler('color',
324-
# ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728',
325-
# '#9467bd', '#8c564b', '#e377c2', '#7f7f7f',
326-
# '#bcbd22', '#17becf'])
324+
# ['1f77b4', 'ff7f0e', '2ca02c', 'd62728',
325+
# '9467bd', '8c564b', 'e377c2', '7f7f7f',
326+
# 'bcbd22', '17becf'])
327327
# color cycle for plot lines
328328
# as list of string colorspecs:
329329
# single letter, long name, or
@@ -383,7 +383,7 @@ backend : $TEMPLATE_BACKEND
383383

384384

385385
### GRIDS
386-
#grid.color : '#b0b0b0' # grid color
386+
#grid.color : b0b0b0 # grid color
387387
#grid.linestyle : - # solid
388388
#grid.linewidth : 1.0 # in points
389389
#grid.alpha : 1.0 # transparency, between 0.0 and 1.0

setupext.py

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from distutils import version
55
from distutils.core import Extension
66
import glob
7-
import io
87
import multiprocessing
98
import os
109
import re
@@ -13,14 +12,53 @@
1312
import sys
1413
import warnings
1514
from textwrap import fill
16-
15+
import shutil
1716
import versioneer
1817

1918

2019
PY3min = (sys.version_info[0] >= 3)
2120
PY32min = (PY3min and sys.version_info[1] >= 2 or sys.version_info[0] > 3)
2221

2322

23+
def _get_home():
24+
"""Find user's home directory if possible.
25+
Otherwise, returns None.
26+
27+
:see:
28+
http://mail.python.org/pipermail/python-list/2005-February/325395.html
29+
"""
30+
try:
31+
if not PY3min and sys.platform == 'win32':
32+
path = os.path.expanduser(b"~").decode(sys.getfilesystemencoding())
33+
else:
34+
path = os.path.expanduser("~")
35+
except ImportError:
36+
# This happens on Google App Engine (pwd module is not present).
37+
pass
38+
else:
39+
if os.path.isdir(path):
40+
return path
41+
for evar in ('HOME', 'USERPROFILE', 'TMP'):
42+
path = os.environ.get(evar)
43+
if path is not None and os.path.isdir(path):
44+
return path
45+
return None
46+
47+
48+
def _get_xdg_cache_dir():
49+
"""
50+
Returns the XDG cache directory, according to the `XDG
51+
base directory spec
52+
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
53+
"""
54+
path = os.environ.get('XDG_CACHE_HOME')
55+
if path is None:
56+
path = _get_home()
57+
if path is not None:
58+
path = os.path.join(path, '.cache', 'matplotlib')
59+
return path
60+
61+
2462
# This is the version of FreeType to use when building a local
2563
# version. It must match the value in
2664
# lib/matplotlib.__init__.py and also needs to be changed below in the
@@ -71,10 +109,13 @@
71109
config.get("directories", "basedirlist").split(',')]
72110

73111
if config.has_option('test', 'local_freetype'):
74-
options['local_freetype'] = config.get("test", "local_freetype")
112+
options['local_freetype'] = config.getboolean("test", "local_freetype")
75113
else:
76114
config = None
77115

116+
lft = bool(os.environ.get('MPLLOCALFREETYPE', False))
117+
options['local_freetype'] = lft or options.get('local_freetype', False)
118+
78119

79120
def get_win32_compiler():
80121
"""
@@ -1008,21 +1049,56 @@ def do_custom_build(self):
10081049

10091050
tarball = 'freetype-{0}.tar.gz'.format(LOCAL_FREETYPE_VERSION)
10101051
tarball_path = os.path.join('build', tarball)
1052+
try:
1053+
tarball_cache_dir = _get_xdg_cache_dir()
1054+
tarball_cache_path = os.path.join(tarball_cache_dir, tarball)
1055+
except:
1056+
# again, do not really care if this fails
1057+
tarball_cache_dir = None
1058+
tarball_cache_path = None
10111059
if not os.path.isfile(tarball_path):
1012-
tarball_url = 'http://download.savannah.gnu.org/releases/freetype/{0}'.format(tarball)
1013-
1014-
print("Downloading {0}".format(tarball_url))
1015-
if sys.version_info[0] == 2:
1016-
from urllib import urlretrieve
1017-
else:
1018-
from urllib.request import urlretrieve
1019-
1020-
if not os.path.exists('build'):
1021-
os.makedirs('build')
1022-
urlretrieve(tarball_url, tarball_path)
1060+
if (tarball_cache_path is not None and
1061+
os.path.isfile(tarball_cache_path)):
1062+
if get_file_hash(tarball_cache_path) == LOCAL_FREETYPE_HASH:
1063+
try:
1064+
# fail on Lpy, oh well
1065+
os.makedirs('build', exist_ok=True)
1066+
shutil.copy(tarball_cache_path, tarball_path)
1067+
print('Using cached tarball: {}'
1068+
.format(tarball_cache_path))
1069+
except:
1070+
# If this fails, oh well just re-download
1071+
pass
1072+
1073+
if not os.path.isfile(tarball_path):
1074+
url_fmt = (
1075+
'http://download.savannah.gnu.org/releases/freetype/{0}')
1076+
tarball_url = url_fmt.format(tarball)
1077+
1078+
print("Downloading {0}".format(tarball_url))
1079+
if sys.version_info[0] == 2:
1080+
from urllib import urlretrieve
1081+
else:
1082+
from urllib.request import urlretrieve
1083+
1084+
if not os.path.exists('build'):
1085+
os.makedirs('build')
1086+
urlretrieve(tarball_url, tarball_path)
1087+
if get_file_hash(tarball_path) == LOCAL_FREETYPE_HASH:
1088+
try:
1089+
# this will fail on LPy, oh well
1090+
os.makedirs(tarball_cache_dir, exist_ok=True)
1091+
shutil.copy(tarball_cache_path, tarball_path)
1092+
print('Cached tarball at: {}'
1093+
.format(tarball_cache_path))
1094+
except:
1095+
# again, we do not care if this fails, can
1096+
# always re download
1097+
pass
10231098

10241099
if get_file_hash(tarball_path) != LOCAL_FREETYPE_HASH:
1025-
raise IOError("{0} does not match expected hash.".format(tarball))
1100+
raise IOError(
1101+
"{0} does not match expected hash.".format(tarball))
10261102

10271103
print("Building {0}".format(tarball))
10281104
if sys.platform != 'win32':
@@ -1048,7 +1124,7 @@ def do_custom_build(self):
10481124
:: move to the "normal" path for the unix builds...
10491125
mkdir %FREETYPE%\\objs\\.libs
10501126
:: REMINDER: fix when changing the version
1051-
copy %FREETYPE%\\objs\\{vc20xx}\\{xXX}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
1127+
copy %FREETYPE%\\objs\\{vc20xx}\\{xXX}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
10521128
if errorlevel 1 (
10531129
rem This is a py27 version, which has a different location for the lib file :-/
10541130
copy %FREETYPE%\\objs\\win32\\{vc20xx}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib

0 commit comments

Comments
 (0)