File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1616"""This module defines class Structure.
1717"""
1818
19- import collections
2019import copy
2120import numpy
2221import codecs
2524from diffpy .structure .lattice import Lattice
2625from diffpy .structure .atom import Atom
2726from diffpy .structure .utils import _linkAtomAttribute , atomBareSymbol
27+ from diffpy .structure .utils import isiterable
2828
2929# ----------------------------------------------------------------------------
3030
@@ -388,7 +388,7 @@ def __getitem__(self, idx):
388388 # check if there is any string label that should be resolved
389389 scalarstringlabel = isinstance (idx , six .string_types )
390390 hasstringlabel = scalarstringlabel or (
391- isinstance (idx , collections . Iterable ) and
391+ isiterable (idx ) and
392392 any (isinstance (ii , six .string_types ) for ii in idx ))
393393 # if not, use numpy indexing to resolve idx
394394 if not hasstringlabel :
Original file line number Diff line number Diff line change 1616"""Small shared functions.
1717"""
1818
19+ import six
1920import numpy
2021
22+ if six .PY2 :
23+ from collections import Iterable as _Iterable
24+ else :
25+ from collections .abc import Iterable as _Iterable
26+
27+
28+ def isiterable (obj ):
29+ """True if argument is iterable."""
30+ rv = isinstance (obj , _Iterable )
31+ return rv
32+
2133
2234def isfloat (s ):
2335 """True if argument can be converted to float"""
You can’t perform that action at this time.
0 commit comments