Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: refine test code to avoid if logic
  • Loading branch information
stevenhua0320 committed Feb 19, 2026
commit 3f285b6ef555f504ae487972a54361e67bdcfe96
15 changes: 4 additions & 11 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def test___copy__(self):

def test_add_new_atom(self):
s_lat = Lattice()
other_lat = Lattice()
expected = Structure(lattice=s_lat)

length = len(expected)
Expand All @@ -131,26 +130,20 @@ def test_add_new_atom(self):
assert len(expected) == actual

object = expected[-1]
if hasattr(object, "element"):
assert object.element == "C"
if hasattr(object, "xyz"):
assert numpy.allclose(object.xyz, [0.1, 0.2, 0.3])
assert object.element == "C"
assert numpy.allclose(object.xyz, [0.1, 0.2, 0.3])

def test_addNewAtom(self):
s_lat = Lattice()
other_lat = Lattice()
expected = Structure(lattice=s_lat)

length = len(expected)
expected.addNewAtom(atype="C", xyz=[0.1, 0.2, 0.3])
actual = length + 1
assert len(expected) == actual

object = expected[-1]
if hasattr(object, "element"):
assert object.element == "C"
if hasattr(object, "xyz"):
assert numpy.allclose(object.xyz, [0.1, 0.2, 0.3])
assert object.element == "C"
assert numpy.allclose(object.xyz, [0.1, 0.2, 0.3])

def test_assignUniqueLabels(self):
"""Check Structure.assignUniqueLabels()"""
Expand Down
Loading