Skip to content
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
21 changes: 1 addition & 20 deletions src/aiida/orm/nodes/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,6 @@ def has_pymatgen():
return True


def get_pymatgen_version():
""":return: string with pymatgen version, None if can not import."""
if not has_pymatgen():
return None
try:
from pymatgen import __version__
except ImportError:
# this was changed in version 2022.0.3
from pymatgen.core import __version__
return __version__


def has_spglib():
""":return: True if the spglib module can be imported, False otherwise."""
try:
Expand Down Expand Up @@ -1827,14 +1815,7 @@ def _get_object_pymatgen_structure(self, **kwargs):
if len(kind.symbols) != 1 or (len(kind.weights) != 1 or sum(kind.weights) < 1.0):
raise ValueError('Cannot set partial occupancies and spins at the same time')
spin = -1 if kind.name.endswith('1') else 1 if kind.name.endswith('2') else 0
try:
specie = Specie(kind.symbols[0], oxidation_state, properties={'spin': spin})
except TypeError:
# As of v2023.9.2, the ``properties`` argument is removed and the ``spin`` argument should be used.
# See: https://github.com/materialsproject/pymatgen/commit/118c245d6082fe0b13e19d348fc1db9c0d512019
# The ``spin`` argument was introduced in v2023.6.28.
# See: https://github.com/materialsproject/pymatgen/commit/9f2b3939af45d5129e0778d371d814811924aeb6
specie = Specie(kind.symbols[0], oxidation_state, spin=spin)
specie = Specie(kind.symbols[0], oxidation_state, spin=spin)
species.append(specie)
else:
# case when no spin are defined
Expand Down
6 changes: 0 additions & 6 deletions tests/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
_atomic_masses,
ase_refine_cell,
get_formula,
get_pymatgen_version,
has_ase,
has_pymatgen,
has_spglib,
Expand Down Expand Up @@ -70,11 +69,6 @@ def simplify(string):
skip_pymatgen = pytest.mark.skipif(not has_pymatgen(), reason='Unable to import pymatgen')


@skip_pymatgen
def test_get_pymatgen_version():
assert isinstance(get_pymatgen_version(), str)


class TestCifData:
"""Tests for CifData class."""

Expand Down