Skip to content

Commit ddb4b45

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
Conflicts: lib/matplotlib/axes/_axes.py lib/matplotlib/backends/backend_pgf.py
2 parents b4c9ced + 3d5a6bb commit ddb4b45

File tree

9 files changed

+112
-68
lines changed

9 files changed

+112
-68
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@ script:
3535
- python ../matplotlib/tests.py -sv --processes=8 --process-timeout=300
3636

3737
after_failure:
38-
- cd ../tmp_test_dir
39-
- tar cjf result_images.tar.bz2 result_images
40-
- travis-artifacts upload --path result_images.tar.bz2
41-
- echo https://s3.amazonaws.com/matplotlib-test-results/artifacts/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NUMBER}/result_images.tar.bz2
38+
- cd ../matplotlib
39+
- ./travis_upload.sh

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5376,11 +5376,11 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
53765376
xvals, yvals = [], []
53775377
for m in n:
53785378
# starting point for drawing polygon
5379-
y[0] = y[-1]
5379+
y[0] = y[1]
53805380
# top of the previous polygon becomes the bottom
53815381
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
53825382
# set the top of this polygon
5383-
y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = m, m
5383+
y[1:2*len(bins)-1:2], y[2:2*len(bins)-1:2] = m, m
53845384
if log:
53855385
y[y < minimum] = minimum
53865386
if orientation == 'horizontal':
@@ -5399,8 +5399,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
53995399
closed=True,
54005400
facecolor=c))
54015401
else:
5402-
for x, y, c in reversed(list(zip(xvals, yvals, color))):
5403-
split = int(len(x) / 2) + 1
5402+
for x, y, c in reversed(zip(xvals, yvals, color)):
5403+
split = 2 * len(bins)
54045404
patches.append(self.fill(
54055405
x[:split], y[:split],
54065406
closed=False, edgecolor=c,

lib/matplotlib/tests/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ def setup():
1414
# The baseline images are created in this locale, so we should use
1515
# it during all of the tests.
1616
import locale
17-
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
17+
import warnings
18+
19+
try:
20+
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
21+
except:
22+
try:
23+
locale.setlocale(locale.LC_ALL, str('English_United States.1252'))
24+
except:
25+
warnings.warn(
26+
"Could not set locale to English/United States. "
27+
"Some date-related tests may fail")
1828

1929
use('Agg', warn=False) # use Agg backend for these tests
2030

Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,17 @@ def test_hist_offset():
11211121
ax.hist(d2, bottom=15)
11221122

11231123

1124+
@image_comparison(baseline_images=['hist_step'], extensions=['png'], remove_text=True)
1125+
def test_hist_step():
1126+
# make some data
1127+
d1 = np.linspace(1, 3, 20)
1128+
fig = plt.figure()
1129+
ax = fig.add_subplot(111)
1130+
ax.hist( d1, histtype="step")
1131+
ax.set_ylim(0, 10)
1132+
ax.set_xlim(-1, 5)
1133+
1134+
11241135
@image_comparison(baseline_images=['hist_stacked_weights'])
11251136
def test_hist_stacked_weighted():
11261137
# make some data

lib/matplotlib/tri/triinterpolate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,8 @@ def compute_dof_from_df(self):
10541054
gradient.
10551055
"""
10561056
J = CubicTriInterpolator._get_jacobian(self._tris_pts)
1057-
tri_z = self.z[self._triangles, :]
1058-
tri_dz = self.dz[self._triangles, :]
1057+
tri_z = self.z[self._triangles]
1058+
tri_dz = self.dz[self._triangles]
10591059
tri_dof = self.get_dof_vec(tri_z, tri_dz, J)
10601060
return tri_dof
10611061

setup.cfg.template

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@
5454
# otherwise skip silently. This is the default
5555
# behavior
5656
#
57+
#agg = auto
58+
#cairo = auto
5759
#gtk = auto
60+
#gtk3agg = auto
61+
#gtk3cairo = auto
5862
#gtkagg = auto
59-
#tkagg = auto
6063
#macosx = auto
64+
#pyside = auto
65+
#qt4agg = auto
66+
#tkagg = auto
6167
#windowing = auto
62-
#gtk3cairo = auto
63-
#gtk3agg = auto
68+
#wxagg = auto
6469

6570
[rc_options]
6671
# User-configurable options

setupext.py

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -438,38 +438,66 @@ def _check_for_pkg_config(self, package, include_file, min_version=None,
438438

439439
class OptionalPackage(SetupPackage):
440440
optional = True
441+
force = False
442+
config_category = "packages"
441443

442444
def get_config(self):
443-
install = True
444-
if config is not None:
445-
try:
446-
install = config.getboolean(
447-
'packages', self.name)
448-
except:
449-
pass
450-
return install
445+
"""
446+
Look at `setup.cfg` and return one of ["auto", True, False] indicating
447+
if the package is at default state ("auto"), forced by the user (True)
448+
or opted-out (False).
449+
"""
450+
try:
451+
return config.getboolean(self.config_category, self.name)
452+
except:
453+
return "auto"
451454

452455
def check(self):
453-
self.install = self.get_config()
454-
if not self.install:
455-
raise CheckFailed("skipping due to configuration")
456-
return "installing"
456+
"""
457+
Do not override this method!
457458
459+
For custom dependency checks override self.check_requirements().
460+
Two things are checked: Configuration file and requirements.
461+
"""
462+
# Check configuration file
463+
conf = self.get_config()
464+
# Default "auto" state or install forced by user
465+
if conf in [True, 'auto']:
466+
message = "installing"
467+
# Set non-optional if user sets `True` in config
468+
if conf is True:
469+
self.optional = False
470+
# Configuration opt-out by user
471+
else:
472+
# Some backend extensions (e.g. Agg) need to be built for certain
473+
# other GUI backends (e.g. TkAgg) even when manually disabled
474+
if self.force is True:
475+
message = "installing forced (config override)"
476+
else:
477+
raise CheckFailed("skipping due to configuration")
458478

459-
class OptionalBackendPackage(SetupPackage):
460-
optional = True
479+
# Check requirements and add extra information (if any) to message.
480+
# If requirements are not met a CheckFailed should be raised in there.
481+
additional_info = self.check_requirements()
482+
if additional_info:
483+
message += ", " + additional_info
484+
485+
# No CheckFailed raised until now, return install message.
486+
return message
487+
488+
def check_requirements(self):
489+
"""
490+
Override this method to do custom dependency checks.
491+
492+
- Raise CheckFailed() if requirements are not met.
493+
- Return message with additional information, or an empty string
494+
(or None) for no additional information.
495+
"""
496+
return ""
461497

462-
def get_config(self):
463-
install = 'auto'
464-
if config is not None:
465-
try:
466-
install = config.getboolean(
467-
'gui_support', self.name)
468-
except:
469-
install = 'auto'
470-
if install is True:
471-
self.optional = False
472-
return install
498+
499+
class OptionalBackendPackage(OptionalPackage):
500+
config_category = "gui_support"
473501

474502

475503
class Platform(SetupPackage):
@@ -1025,16 +1053,6 @@ def get_install_requires(self):
10251053

10261054
class BackendAgg(OptionalBackendPackage):
10271055
name = "agg"
1028-
force = False
1029-
1030-
def check(self):
1031-
# The Agg backend extension needs to be built even
1032-
# for certain GUI backends, such as TkAgg
1033-
config = self.get_config()
1034-
if config is False and self.force is False:
1035-
raise CheckFailed("skipping due to configuration")
1036-
else:
1037-
return "installing"
10381056

10391057
def get_extension(self):
10401058
sources = [
@@ -1056,10 +1074,7 @@ class BackendTkAgg(OptionalBackendPackage):
10561074
def __init__(self):
10571075
self.tcl_tk_cache = None
10581076

1059-
def check(self):
1060-
if self.get_config() is False:
1061-
raise CheckFailed("skipping due to configuration")
1062-
1077+
def check_requirements(self):
10631078
try:
10641079
if PY3:
10651080
import tkinter as Tkinter
@@ -1345,10 +1360,7 @@ def add_flags(self, ext):
13451360
class BackendGtk(OptionalBackendPackage):
13461361
name = "gtk"
13471362

1348-
def check(self):
1349-
if self.get_config() is False:
1350-
raise CheckFailed("skipping due to configuration")
1351-
1363+
def check_requirements(self):
13521364
try:
13531365
import gtk
13541366
except ImportError:
@@ -1503,7 +1515,7 @@ def backend_gtk3agg_internal_check(x):
15031515
class BackendGtk3Agg(OptionalBackendPackage):
15041516
name = "gtk3agg"
15051517

1506-
def check(self):
1518+
def check_requirements(self):
15071519
if 'TRAVIS' in os.environ:
15081520
raise CheckFailed("Can't build with Travis")
15091521

@@ -1568,7 +1580,7 @@ def backend_gtk3cairo_internal_check(x):
15681580
class BackendGtk3Cairo(OptionalBackendPackage):
15691581
name = "gtk3cairo"
15701582

1571-
def check(self):
1583+
def check_requirements(self):
15721584
if 'TRAVIS' in os.environ:
15731585
raise CheckFailed("Can't build with Travis")
15741586

@@ -1596,7 +1608,7 @@ def get_package_data(self):
15961608
class BackendWxAgg(OptionalBackendPackage):
15971609
name = "wxagg"
15981610

1599-
def check(self):
1611+
def check_requirements(self):
16001612
try:
16011613
import wxversion
16021614
except ImportError:
@@ -1634,10 +1646,7 @@ def check(self):
16341646
class BackendMacOSX(OptionalBackendPackage):
16351647
name = 'macosx'
16361648

1637-
def check(self):
1638-
if self.get_config() is False:
1639-
raise CheckFailed("skipping due to configuration")
1640-
1649+
def check_requirements(self):
16411650
if sys.platform != 'darwin':
16421651
raise CheckFailed("Mac OS-X only")
16431652

@@ -1664,7 +1673,7 @@ class Windowing(OptionalBackendPackage):
16641673
"""
16651674
name = "windowing"
16661675

1667-
def check(self):
1676+
def check_requirements(self):
16681677
if sys.platform != 'win32':
16691678
raise CheckFailed("Microsoft Windows only")
16701679
config = self.get_config()
@@ -1695,7 +1704,7 @@ def convert_qt_version(self, version):
16951704
temp.insert(0, str(int(chunk, 16)))
16961705
return '.'.join(temp)
16971706

1698-
def check(self):
1707+
def check_requirements(self):
16991708
try:
17001709
from PyQt4 import pyqtconfig
17011710
except ImportError:
@@ -1715,7 +1724,7 @@ def check(self):
17151724
class BackendPySide(OptionalBackendPackage):
17161725
name = "pyside"
17171726

1718-
def check(self):
1727+
def check_requirements(self):
17191728
try:
17201729
from PySide import __version__
17211730
from PySide import QtCore
@@ -1731,7 +1740,7 @@ def check(self):
17311740
class BackendCairo(OptionalBackendPackage):
17321741
name = "cairo"
17331742

1734-
def check(self):
1743+
def check_requirements(self):
17351744
try:
17361745
import cairo
17371746
except ImportError:

travis_upload.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd ../tmp_test_dir
6+
echo "Compressing results"
7+
tar cjf result_images.tar.bz2 result_images
8+
echo "Uploading results"
9+
travis-artifacts upload --path result_images.tar.bz2
10+
echo "Results available at:"
11+
echo https://s3.amazonaws.com/matplotlib-test-results/artifacts/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NUMBER}/result_images.tar.bz2

0 commit comments

Comments
 (0)