We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ca9116a + 793f5b0 commit 0762314Copy full SHA for 0762314
news/deprecate-getLastAtom.rst
@@ -0,0 +1,23 @@
1
+**Added:**
2
+
3
+* Added `diffpy.structure.Structure.get_last_atom` in replace of `getLastAtom`
4
5
+**Changed:**
6
7
+* <news item>
8
9
+**Deprecated:**
10
11
+* Deprecated `diffpy.structure.Structure.getLastAtom` for removal in version 4.0.0
12
13
+**Removed:**
14
15
16
17
+**Fixed:**
18
19
20
21
+**Security:**
22
23
src/diffpy/structure/parsers/p_cif.py
@@ -498,7 +498,7 @@ def _parse_atom_site_label(self, block):
498
continue
499
self.labelindex[curlabel] = len(self.stru)
500
self.stru.add_new_atom()
501
- a = self.stru.getLastAtom()
+ a = self.stru.get_last_atom()
502
for fset, val in zip(prop_setters, values):
503
fset(a, val)
504
if does_adp_type:
src/diffpy/structure/parsers/p_discus.py
@@ -265,7 +265,7 @@ def _parse_atom(self, words):
265
xyz = [float(w) for w in words[1:4]]
266
Biso = float(words[4])
267
self.stru.add_new_atom(element, xyz)
268
269
a.Bisoequiv = Biso
270
return
271
src/diffpy/structure/parsers/p_pdb.py
@@ -198,7 +198,7 @@ def parseLines(self, lines):
198
element = line[12:14].strip()
199
element = element[0].upper() + element[1:].lower()
200
stru.add_new_atom(element, occupancy=occupancy, label=name)
201
- last_atom = stru.getLastAtom()
+ last_atom = stru.get_last_atom()
202
last_atom.xyz_cartn = rc
203
last_atom.Uisoequiv = uiso
204
elif record == "SIGATM":
src/diffpy/structure/parsers/p_pdffit.py
@@ -133,7 +133,7 @@ def parseLines(self, lines):
133
xyz = [float(w) for w in wl1[1:4]]
134
occ = float(wl1[4])
135
stru.add_new_atom(element, xyz=xyz, occupancy=occ)
136
- a = stru.getLastAtom()
+ a = stru.get_last_atom()
137
p_nl += 1
138
wl2 = next(ilines).split()
139
a.sigxyz = [float(w) for w in wl2[0:3]]
src/diffpy/structure/structure.py
@@ -34,6 +34,12 @@
34
"add_new_atom",
35
removal_version,
36
)
37
+getLastAtom_deprecation_msg = build_deprecation_message(
38
+ base,
39
+ "getLastAtom",
40
+ "get_last_atom",
41
+ removal_version,
42
+)
43
44
45
class Structure(list):
@@ -192,7 +198,16 @@ def add_new_atom(self, *args, **kwargs):
192
self.append(atom, copy=False)
193
194
+ @deprecated(getLastAtom_deprecation_msg)
195
def getLastAtom(self):
+ """This function has been deprecated and will be removed in
+ version 4.0.0.
205
206
+ Please use diffpy.structure.Structure.get_last_atom instead.
207
+ """
208
+ return self.get_last_atom()
209
210
+ def get_last_atom(self):
196
211
"""Return Reference to the last `Atom` in this structure."""
197
212
last_atom = self[-1]
213
return last_atom
tests/test_structure.py
@@ -119,6 +119,23 @@ def test___copy__(self):
119
# def test_getLastAtom(self):
120
# """check Structure.getLastAtom()"""
121
# return
122
+ def test_getLastAtom(self):
123
+ """Check Structure.getLastAtom()"""
124
+ s_lat = Lattice()
125
+ expected = Atom("C", [0, 0, 0])
126
+ structure = Structure(atoms=[Atom("C", [0, 0, 0])], lattice=s_lat)
127
+ actual = structure.getLastAtom()
128
+ assert actual.element == expected.element
129
+ assert numpy.allclose(expected.xyz, actual.xyz)
130
131
+ def test_get_last_atom(self):
132
+ """Check Structure.get_last_atom()"""
+ actual = structure.get_last_atom()
140
def test_addNewAtom(self):
141
"""Duplicate test for the deprecated addNewAtom method.
0 commit comments