Skip to content

Commit 48c115e

Browse files
committed
get_isotropic_displacement_parameters tests and func
1 parent 37f6426 commit 48c115e

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

src/diffpy/structure/structure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ def get_anisotropic_displacement_parameters(self):
224224
numpy.ndarray
225225
The array of anisotropic displacement parameters of all `Atoms` in this structure.
226226
"""
227-
adps = numpy.array([a.U for a in self])
228-
return adps
227+
aniso_adps = numpy.array([a.U for a in self])
228+
return aniso_adps
229229

230230
def get_isotropic_displacement_parameters(self):
231231
"""Return array of isotropic displacement parameters of all
@@ -236,8 +236,8 @@ def get_isotropic_displacement_parameters(self):
236236
numpy.ndarray
237237
The array of isotropic displacement parameters of all `Atoms` in this structure.
238238
"""
239-
idps = numpy.array([a.Uisoequiv for a in self])
240-
return idps
239+
iso_adps = numpy.array([a.Uisoequiv for a in self])
240+
return iso_adps
241241

242242
def get_occupancies(self):
243243
"""Return array of occupancies of all `Atoms` in this structure.

tests/test_structure.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,30 @@ def test_get_cartesian_coordinates(datafile):
652652
assert numpy.allclose(actual_cartesian_coords, expected_cartesian_coords)
653653

654654

655-
# def test_get_anisotropic_displacement_parameters(datafile):
656-
# """Check Structure.get_anisotropic_displacement_parameters()"""
657-
# assert False
655+
def test_get_anisotropic_displacement_parameters(datafile):
656+
"""Check Structure.get_anisotropic_displacement_parameters()"""
657+
tei_stru = Structure(filename=datafile("TeI.cif"))
658+
actual_displacement = tei_stru.get_anisotropic_displacement_parameters()
659+
expected_one_atom = numpy.array(
660+
[
661+
[[0.0211, 0.0, 0.0109], [0.0, 0.0195, 0.0], [0.0109, 0.0, 0.016]],
662+
[[0.0223, 0.0, 0.0179], [0.0, 0.018, 0.0], [0.0179, 0.0, 0.0254]],
663+
[[0.025, 0.0, 0.0226], [0.0, 0.0234, 0.0], [0.0226, 0.0, 0.0345]],
664+
[[0.0234, 0.0, 0.0138], [0.0, 0.0295, 0.0], [0.0138, 0.0, 0.0253]],
665+
]
666+
)
667+
expected_displacement = numpy.repeat(expected_one_atom, 4, axis=0)
668+
assert numpy.allclose(actual_displacement, expected_displacement)
658669

659670

660-
# def test_get_isotropic_displacement_parameters(datafile):
661-
# """Check Structure.get_isotropic_displacement_parameters()"""
662-
# assert False
671+
def test_get_isotropic_displacement_parameters(datafile):
672+
"""Check Structure.get_isotropic_displacement_parameters()"""
673+
pbte_stru = Structure(filename=datafile("PbTe.cif"))
674+
actual_isotropic_displacement = pbte_stru.get_isotropic_displacement_parameters()
675+
expected_isotropic_displacement = numpy.array(
676+
[0.0225566, 0.0225566, 0.0225566, 0.0225566, 0.0155528, 0.0155528, 0.0155528, 0.0155528]
677+
)
678+
assert numpy.allclose(actual_isotropic_displacement, expected_isotropic_displacement)
663679

664680

665681
# def test_get_occupancies(datafile):

0 commit comments

Comments
 (0)