Skip to content

Commit 6191146

Browse files
committed
MNT: avoid name clash for copy module
Import it as `copymod` so it does not shadow argument name.
1 parent 5ba9300 commit 6191146

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/diffpy/structure/structure.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""This module defines class Structure.
1717
"""
1818

19-
import copy
19+
import copy as copymod
2020
import numpy
2121
import codecs
2222
import six
@@ -95,9 +95,9 @@ def __init__(self, atoms=None, lattice=None, title=None,
9595

9696

9797
def copy(self):
98-
'''Return a deep copy of this Structure object.
98+
'''Return a copy of this Structure object.
9999
'''
100-
return copy.copy(self)
100+
return copymod.copy(self)
101101

102102

103103
def __copy__(self, target=None):
@@ -116,7 +116,7 @@ def __copy__(self, target=None):
116116
# copy attributes as appropriate:
117117
target.title = self.title
118118
target.lattice = Lattice(self.lattice)
119-
target.pdffit = copy.deepcopy(self.pdffit)
119+
target.pdffit = copymod.deepcopy(self.pdffit)
120120
# copy all atoms to the target
121121
target[:] = self
122122
return target
@@ -332,7 +332,7 @@ def insert(self, idx, a, copy=True):
332332
333333
No return value.
334334
"""
335-
adup = copy and Atom(a) or a
335+
adup = copy and copymod.copy(a) or a
336336
adup.lattice = self.lattice
337337
super(Structure, self).insert(idx, adup)
338338
return
@@ -464,7 +464,7 @@ def __add__(self, other):
464464
465465
Return new Structure with a copy of Atom instances.
466466
'''
467-
rv = copy.copy(self)
467+
rv = copymod.copy(self)
468468
rv += other
469469
return rv
470470

@@ -489,7 +489,7 @@ def __sub__(self, other):
489489
'''
490490
otherset = set(other)
491491
keepindices = [i for i, a in enumerate(self) if not a in otherset]
492-
rv = copy.copy(self[keepindices])
492+
rv = copymod.copy(self[keepindices])
493493
return rv
494494

495495

@@ -513,7 +513,7 @@ def __mul__(self, n):
513513
514514
Return new Structure.
515515
'''
516-
rv = copy.copy(self[:0])
516+
rv = copymod.copy(self[:0])
517517
rv += n * self.tolist()
518518
return rv
519519

src/diffpy/structure/tests/teststructure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_extend(self):
240240
self.assertEqual(6, len(stru))
241241
self.assertTrue(all(a.lattice is stru.lattice for a in stru))
242242
self.assertEqual(lst, stru.tolist()[:2])
243-
self.assertNotEqual(stru[-1], cdse[-1])
243+
self.assertFalse(stru[-1] is cdse[-1])
244244
return
245245

246246

0 commit comments

Comments
 (0)