Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filter condition for warn msg of unphysical site occupancy in io.cif #3853

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pymatgen/io/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def get_matching_coord(

if any(occu > 1 for occu in _sum_occupancies):
msg = (
f"Some occupancies ({filter(lambda x: x<=1, _sum_occupancies)}) sum to > 1! If they are within "
f"Some occupancies ({list(filter(lambda x: x>1, _sum_occupancies))}) sum to > 1! If they are within "
"the occupancy_tolerance, they will be rescaled. "
f"The current occupancy_tolerance is set to: {self._occupancy_tolerance}"
)
Expand Down
5 changes: 4 additions & 1 deletion tests/io/test_cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,10 @@ def test_not_check_occu(self):
cif_str = cif_file.read()
cif_str = cif_str.replace("Te Te 1.0000", "Te_label Te 10.0", 1)

structs = CifParser.from_str(cif_str).parse_structures(check_occu=False)
with pytest.warns(
UserWarning, match=r"Issues encountered while parsing CIF: Some occupancies \(\[10\.0\]\) sum to > 1!"
):
structs = CifParser.from_str(cif_str).parse_structures(check_occu=False)

assert len(structs) > 0
assert set(structs[0].labels) == {"Te_label", "Ge"}
Expand Down