Skip to content

Commit 11d0860

Browse files
committed
BUG: fix PY2 slice handling in Atom class
Override `__setslice__` from the base ndarray class.
1 parent 998a2f4 commit 11d0860

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/diffpy/structure/atom.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"""
1919

2020
import numpy
21+
import six
22+
2123
from diffpy.structure.lattice import cartesian as cartesian_lattice
2224

2325
# conversion constants
@@ -530,4 +532,14 @@ def __array_wrap__(self, out_arr, context=None):
530532
"""
531533
return out_arr.view(numpy.ndarray)
532534

535+
# Python 2 Compatibility -------------------------------------------------
536+
537+
if six.PY2:
538+
539+
def __setslice__(self, lo, hi, sequence):
540+
self.__setitem__(slice(lo, hi), sequence)
541+
return
542+
543+
# ------------------------------------------------------------------------
544+
533545
# End of _AtomCartesianCoordinates

0 commit comments

Comments
 (0)