Skip to content

Commit

Permalink
Avoid using __contains__ for spglib dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Aug 22, 2024
1 parent 9f67977 commit 504aa59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions phonopy/interface/phonopy_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,13 @@ def _symmetry_yaml_lines(self):

dataset = self._data.symmetry.dataset
if dataset is not None:
if "uni_number" in dataset:
try:
uni_number = dataset.uni_number
lines.append("magnetic_space_group:")
lines.append(f" uni_number: {dataset.uni_number}")
lines.append(f" uni_number: {uni_number}")
lines.append(f" msg_type: {dataset.msg_type}")
lines.append("")
else:
except AttributeError:
lines.append("space_group:")
spg_type = dataset.international
lines.append(f' type: "{spg_type}"')
Expand Down
6 changes: 1 addition & 5 deletions phonopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,4 @@ def get_dot_access_dataset(dataset):
else:
from types import SimpleNamespace

class MySimpleNamespace(SimpleNamespace):
def __contains__(self, key):
return key in self.__dict__

return MySimpleNamespace(**dataset)
return SimpleNamespace(**dataset)
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def ph_nacl_rd_symfc() -> Phonopy:
"""
pytest.importorskip("symfc")
pytest.importorskip("spglib", minversion="2.5")

yaml_filename = cwd / "phonopy_params_NaCl-rd.yaml.xz"
return phonopy.load(
Expand Down

0 comments on commit 504aa59

Please sign in to comment.