1111import six
1212from six .moves import xrange , zip
1313import collections
14+ try :
15+ import collections .abc as cabc
16+ except ImportError :
17+ import collections as cabc
18+
1419import contextlib
1520import datetime
1621import 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
23542360def 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
23702376def 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
23752382def normalize_kwargs (kw , alias_mapping = None , required = (), forbidden = (),
0 commit comments