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

Skip to content

Commit e435c63

Browse files
anntzertacaswell
authored andcommitted
Merge pull request #11733 from andyfaff/collection
MAINT: use collections.abc for 3.7 Conflicts: lib/matplotlib/cbook/__init__.py Added try-except block to handle py2 case
1 parent f209062 commit e435c63

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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=(),

0 commit comments

Comments
 (0)