Skip to content

Commit

Permalink
Simplify get_dot_access_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Sep 10, 2024
1 parent 9edcb8b commit f7e1208
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions phonopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from importlib.metadata import version

import numpy as np
from packaging.version import Version


def similarity_transformation(rot, mat):
Expand All @@ -52,9 +49,13 @@ def get_dot_access_dataset(dataset):
To emulate it for older versions, this function is used.
"""
if Version(version("spglib")) >= Version("2.5"):
return dataset
else:
import spglib

spg_version = tuple(int(v) for v in spglib.__version__.split(".")[:3])

if spg_version < (2, 5, 0):
from types import SimpleNamespace

return SimpleNamespace(**dataset)
else:
return dataset

0 comments on commit f7e1208

Please sign in to comment.