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

Skip to content

Commit 5e63281

Browse files
authored
Merge pull request #15191 from tacaswell/auto-backport-of-pr-11786-on-v2.2.x
Merge pull request #11786 from timhoffm/collections-abc
2 parents 053eea9 + e435c63 commit 5e63281

5 files changed

Lines changed: 26 additions & 9 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@
104104
import six
105105

106106
import atexit
107-
from collections import MutableMapping
107+
try:
108+
from collections.abc import MutableMapping
109+
except ImportError:
110+
from collections import MutableMapping
108111
import contextlib
109112
import distutils.version
110113
import functools

lib/matplotlib/cbook/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
import six
1212
from six.moves import xrange, zip
1313
import collections
14+
try:
15+
import collections.abc as cabc
16+
except ImportError:
17+
import collections as cabc
18+
1419
import contextlib
1520
import datetime
1621
import errno
@@ -2293,7 +2298,8 @@ def pts_to_midstep(x, *args):
22932298
The x location of the steps. May be empty.
22942299
22952300
y1, ..., yp : array
2296-
y arrays to be turned into steps; all must be the same length as ``x``.
2301+
y arrays to be turned into steps; all must be the same length as
2302+
``x``.
22972303
22982304
Returns
22992305
-------
@@ -2352,7 +2358,7 @@ def index_of(y):
23522358

23532359

23542360
def safe_first_element(obj):
2355-
if isinstance(obj, collections.Iterator):
2361+
if isinstance(obj, cabc.Iterator):
23562362
# needed to accept `array.flat` as input.
23572363
# np.flatiter reports as an instance of collections.Iterator
23582364
# but can still be indexed via [].
@@ -2369,7 +2375,8 @@ def safe_first_element(obj):
23692375

23702376
def sanitize_sequence(data):
23712377
"""Converts dictview object to list"""
2372-
return list(data) if isinstance(data, collections.MappingView) else data
2378+
return (list(data) if isinstance(data, cabc.MappingView)
2379+
else data)
23732380

23742381

23752382
def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),

lib/matplotlib/colors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
import six
5151
from six.moves import zip
5252

53-
from collections import Sized
53+
try:
54+
from collections.abc import Sized
55+
except ImportError:
56+
from collections import Sized
5457
import itertools
5558
import re
5659
import warnings

lib/matplotlib/markers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@
8888

8989
import six
9090
from six.moves import xrange
91-
92-
from collections import Sized
91+
try:
92+
from collections.abc import Sized
93+
except ImportError:
94+
from collections import Sized
9395

9496
import numpy as np
9597

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
from __future__ import absolute_import, division, print_function
1717

1818
import six
19-
20-
from collections import Iterable, Mapping
19+
try:
20+
from collections.abc import Iterable, Mapping
21+
except ImportError:
22+
from collections import Iterable, Mapping
2123
from functools import reduce
2224
import operator
2325
import os

0 commit comments

Comments
 (0)