Skip to content

Commit ae3de41

Browse files
Merge branch 'master' into mpl-17508
2 parents 09f62a4 + 81f0624 commit ae3de41

File tree

15 files changed

+87
-57
lines changed

15 files changed

+87
-57
lines changed

.github/workflows/tests.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ jobs:
2222
matrix:
2323
include:
2424
- name-suffix: "(Minimum Versions)"
25-
os: ubuntu-16.04
25+
os: ubuntu-18.04
2626
python-version: 3.7
2727
extra-requirements: '-c requirements/testing/minver.txt'
2828
pyqt5-ver: '==5.8 sip==4.19.7' # oldest versions with a Py3.7 wheel.
2929
delete-font-cache: true
3030
XVFB_RUN: xvfb-run -a
31-
- os: ubuntu-16.04
31+
- os: ubuntu-18.04
3232
python-version: 3.7
3333
extra-requirements: '-r requirements/testing/extra.txt'
3434
XVFB_RUN: xvfb-run -a
3535
CFLAGS: "-fno-lto" # Ensure that disabling LTO works.
36-
- os: ubuntu-16.04
36+
- os: ubuntu-18.04
3737
python-version: 3.8
3838
extra-requirements: '-r requirements/testing/extra.txt'
3939
XVFB_RUN: xvfb-run -a
@@ -128,10 +128,10 @@ jobs:
128128
~/.cache/matplotlib
129129
!~/.cache/matplotlib/tex.cache
130130
!~/.cache/matplotlib/test_cache
131-
key: ${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}-${{ github.sha }}
131+
key: 1-${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}-${{ github.sha }}
132132
restore-keys: |
133-
${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}-
134-
${{ runner.os }}-py${{ matrix.python-version }}-mpl-
133+
1-${{ runner.os }}-py${{ matrix.python-version }}-mpl-${{ github.ref }}-
134+
1-${{ runner.os }}-py${{ matrix.python-version }}-mpl-
135135
136136
- name: Install Python dependencies
137137
run: |
@@ -156,12 +156,8 @@ jobs:
156156
# libraries cannot be loaded at runtime, so an actual import is a
157157
# better check).
158158
if [[ "${{ runner.os }}" != 'macOS' ]]; then
159-
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12;
160-
# pycairo 1.20+ requires a new version of Cairo, unavailable on
161-
# Ubuntu 16.04, so PyGObject must be installed without build
162-
# isolation in order to pick up the lower pre-installed version.
163-
python -m pip install --upgrade 'pycairo<1.20.0' 'cairocffi>=0.8' &&
164-
python -m pip install --upgrade --no-build-isolation PyGObject &&
159+
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12.
160+
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
165161
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
166162
echo 'PyGObject is available' ||
167163
echo 'PyGObject is not available'
@@ -180,7 +176,7 @@ jobs:
180176
echo 'PySide2 is not available'
181177
fi
182178
python -m pip install --upgrade \
183-
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 \
179+
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 \
184180
wxPython &&
185181
python -c 'import wx' &&
186182
echo 'wxPython is available' ||
@@ -226,3 +222,9 @@ jobs:
226222
if: ${{ runner.os != 'macOS' }}
227223
- name: Upload code coverage
228224
uses: codecov/codecov-action@v1
225+
226+
- uses: actions/upload-artifact@v2
227+
if: failure()
228+
with:
229+
name: "${{ matrix.python-version }} ${{ matrix.os }} ${{ matrix.name-suffix }} result images"
230+
path: ./result_images

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
strategy:
77
matrix:
88
Linux_py37:
9-
vmImage: 'ubuntu-16.04'
9+
vmImage: 'ubuntu-18.04'
1010
python.version: '3.7'
1111
Linux_py38:
12-
vmImage: 'ubuntu-16.04'
12+
vmImage: 'ubuntu-18.04'
1313
python.version: '3.8'
1414
Linux_py39:
15-
vmImage: 'ubuntu-16.04'
15+
vmImage: 'ubuntu-18.04'
1616
python.version: '3.9'
1717
macOS_py37:
1818
vmImage: 'macOS-10.15'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``cbook.report_memory``
2+
~~~~~~~~~~~~~~~~~~~~~~~
3+
... is deprecated. Use ``psutil.virtual_memory`` instead.

examples/axes_grid1/simple_axes_divider1.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
=====================
33
Simple Axes Divider 1
44
=====================
5+
6+
See also :doc:`/tutorials/toolkits/axes_grid`.
57
"""
68

79
from mpl_toolkits.axes_grid1 import Size, Divider
@@ -16,51 +18,48 @@ def label_axes(ax, text):
1618
left=False, labelleft=False)
1719

1820

19-
##############################################################################
20-
# Fixed axes sizes; fixed paddings.
21+
fig = plt.figure(figsize=(12, 6))
22+
sfs = fig.subfigures(1, 2)
2123

22-
fig = plt.figure(figsize=(6, 6))
23-
fig.suptitle("Fixed axes sizes, fixed paddings")
2424

25+
sfs[0].suptitle("Fixed axes sizes, fixed paddings")
2526
# Sizes are in inches.
2627
horiz = [Size.Fixed(1.), Size.Fixed(.5), Size.Fixed(1.5), Size.Fixed(.5)]
2728
vert = [Size.Fixed(1.5), Size.Fixed(.5), Size.Fixed(1.)]
2829

2930
rect = (0.1, 0.1, 0.8, 0.8)
3031
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
31-
divider = Divider(fig, rect, horiz, vert, aspect=False)
32+
div = Divider(sfs[0], rect, horiz, vert, aspect=False)
3233

3334
# The rect parameter will actually be ignored and overridden by axes_locator.
34-
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
35+
ax1 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
3536
label_axes(ax1, "nx=0, ny=0")
36-
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
37+
ax2 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
3738
label_axes(ax2, "nx=0, ny=2")
38-
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
39+
ax3 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
3940
label_axes(ax3, "nx=2, ny=2")
40-
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))
41+
ax4 = sfs[0].add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
4142
label_axes(ax4, "nx=2, nx1=4, ny=0")
4243

43-
##############################################################################
44-
# Axes sizes that scale with the figure size; fixed paddings.
45-
46-
fig = plt.figure(figsize=(6, 6))
47-
fig.suptitle("Scalable axes sizes, fixed paddings")
4844

45+
sfs[1].suptitle("Scalable axes sizes, fixed paddings")
46+
# Fixed sizes are in inches, scaled sizes are relative.
4947
horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.), Size.Scaled(.5)]
5048
vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
5149

5250
rect = (0.1, 0.1, 0.8, 0.8)
5351
# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
54-
divider = Divider(fig, rect, horiz, vert, aspect=False)
52+
div = Divider(sfs[1], rect, horiz, vert, aspect=False)
5553

5654
# The rect parameter will actually be ignored and overridden by axes_locator.
57-
ax1 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=0))
55+
ax1 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=0))
5856
label_axes(ax1, "nx=0, ny=0")
59-
ax2 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=0, ny=2))
57+
ax2 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=0, ny=2))
6058
label_axes(ax2, "nx=0, ny=2")
61-
ax3 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, ny=2))
59+
ax3 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=2, ny=2))
6260
label_axes(ax3, "nx=2, ny=2")
63-
ax4 = fig.add_axes(rect, axes_locator=divider.new_locator(nx=2, nx1=4, ny=0))
61+
ax4 = sfs[1].add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
6462
label_axes(ax4, "nx=2, nx1=4, ny=0")
6563

64+
6665
plt.show()

examples/axes_grid1/simple_axes_divider3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
Simple Axes Divider 3
44
=====================
55
6+
See also :doc:`/tutorials/toolkits/axes_grid`.
67
"""
8+
79
import mpl_toolkits.axes_grid1.axes_size as Size
810
from mpl_toolkits.axes_grid1 import Divider
911
import matplotlib.pyplot as plt

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,9 @@ def __init__(self, filename, *, keep_empty=True, metadata=None):
948948
'Creator', 'Producer', 'CreationDate', 'ModDate', and
949949
'Trapped'. Values have been predefined for 'Creator', 'Producer'
950950
and 'CreationDate'. They can be removed by setting them to `None`.
951+
952+
Note that some versions of LaTeX engines may ignore the 'Producer'
953+
key and set it to themselves.
951954
"""
952955
self._output_name = filename
953956
self._n_figures = 0

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ def remove(self, o):
628628
self.push(elem)
629629

630630

631+
@_api.deprecated("3.5", alternative="psutil.virtual_memory")
631632
def report_memory(i=0): # argument may go away
632633
"""Return the memory consumed by the process."""
633634
def call(command, os_name):

lib/matplotlib/cm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ def to_rgba(self, x, alpha=None, bytes=False, norm=True):
361361

362362
def set_array(self, A):
363363
"""
364-
Set the image array from numpy array *A*.
364+
Set the image array from array-like *A*.
365365
366366
Parameters
367367
----------
368-
A : ndarray or None
368+
A : array-like or None
369369
"""
370370
if A is None:
371371
self._A = None
@@ -386,6 +386,12 @@ def set_array(self, A):
386386
'Dimensions of A %s are incompatible with '
387387
'X (%d) and/or Y (%d)' %
388388
(A.shape, width, height))
389+
390+
A = cbook.safe_masked_invalid(A, copy=True)
391+
if not np.can_cast(A.dtype, float, "same_kind"):
392+
raise TypeError(f"Image data of dtype {A.dtype} cannot be "
393+
"converted to float")
394+
389395
self._A = A
390396

391397
def get_array(self):

lib/matplotlib/image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
13461346

13471347
def set_data(self, A):
13481348
"""Set the image array."""
1349-
cm.ScalarMappable.set_array(self,
1350-
cbook.safe_masked_invalid(A, copy=True))
1349+
cm.ScalarMappable.set_array(self, A)
13511350
self.stale = True
13521351

13531352

lib/matplotlib/legend.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,11 @@ def __init__(self, parent, handles, labels,
460460
if not self.isaxes and loc in [0, 'best']:
461461
loc = 'upper right'
462462
if isinstance(loc, str):
463-
if loc not in self.codes:
464-
raise ValueError(
465-
"Unrecognized location {!r}. Valid locations are\n\t{}\n"
466-
.format(loc, '\n\t'.join(self.codes)))
467-
else:
468-
loc = self.codes[loc]
463+
loc = _api.check_getitem(self.codes, loc=loc)
469464
if not self.isaxes and loc == 0:
470465
raise ValueError(
471466
"Automatic legend placement (loc='best') not implemented for "
472-
"figure legend.")
467+
"figure legend")
473468

474469
self._mode = mode
475470
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)

0 commit comments

Comments
 (0)