Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
get_isotropic_displacement_parameters tests and func
  • Loading branch information
cadenmyers13 committed Mar 23, 2026
commit 48c115e19b118256034d263fe7b8cd4f67a90493
8 changes: 4 additions & 4 deletions src/diffpy/structure/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def get_anisotropic_displacement_parameters(self):
numpy.ndarray
The array of anisotropic displacement parameters of all `Atoms` in this structure.
"""
adps = numpy.array([a.U for a in self])
return adps
aniso_adps = numpy.array([a.U for a in self])
return aniso_adps

def get_isotropic_displacement_parameters(self):
"""Return array of isotropic displacement parameters of all
Expand All @@ -236,8 +236,8 @@ def get_isotropic_displacement_parameters(self):
numpy.ndarray
The array of isotropic displacement parameters of all `Atoms` in this structure.
"""
idps = numpy.array([a.Uisoequiv for a in self])
return idps
iso_adps = numpy.array([a.Uisoequiv for a in self])
return iso_adps

def get_occupancies(self):
"""Return array of occupancies of all `Atoms` in this structure.
Expand Down
28 changes: 22 additions & 6 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,14 +652,30 @@ def test_get_cartesian_coordinates(datafile):
assert numpy.allclose(actual_cartesian_coords, expected_cartesian_coords)


# def test_get_anisotropic_displacement_parameters(datafile):
# """Check Structure.get_anisotropic_displacement_parameters()"""
# assert False
def test_get_anisotropic_displacement_parameters(datafile):
"""Check Structure.get_anisotropic_displacement_parameters()"""
tei_stru = Structure(filename=datafile("TeI.cif"))
actual_displacement = tei_stru.get_anisotropic_displacement_parameters()
expected_one_atom = numpy.array(
[
[[0.0211, 0.0, 0.0109], [0.0, 0.0195, 0.0], [0.0109, 0.0, 0.016]],
[[0.0223, 0.0, 0.0179], [0.0, 0.018, 0.0], [0.0179, 0.0, 0.0254]],
[[0.025, 0.0, 0.0226], [0.0, 0.0234, 0.0], [0.0226, 0.0, 0.0345]],
[[0.0234, 0.0, 0.0138], [0.0, 0.0295, 0.0], [0.0138, 0.0, 0.0253]],
]
)
expected_displacement = numpy.repeat(expected_one_atom, 4, axis=0)
assert numpy.allclose(actual_displacement, expected_displacement)


# def test_get_isotropic_displacement_parameters(datafile):
# """Check Structure.get_isotropic_displacement_parameters()"""
# assert False
def test_get_isotropic_displacement_parameters(datafile):
"""Check Structure.get_isotropic_displacement_parameters()"""
pbte_stru = Structure(filename=datafile("PbTe.cif"))
actual_isotropic_displacement = pbte_stru.get_isotropic_displacement_parameters()
expected_isotropic_displacement = numpy.array(
[0.0225566, 0.0225566, 0.0225566, 0.0225566, 0.0155528, 0.0155528, 0.0155528, 0.0155528]
)
assert numpy.allclose(actual_isotropic_displacement, expected_isotropic_displacement)


# def test_get_occupancies(datafile):
Expand Down