Skip to content

Commit

Permalink
Use simple bools in pymatgen Structure converter (#2021)
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Mar 29, 2024
1 parent e8eff68 commit a1a71b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions optimade/adapters/structures/pymatgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

from typing import Optional, Union
from warnings import warn

from optimade.adapters.structures.utils import (
species_from_species_at_sites,
Expand All @@ -23,13 +24,12 @@
from pymatgen.core import Lattice, Molecule, Structure

except (ImportError, ModuleNotFoundError):
from warnings import warn

from optimade.adapters.warnings import AdapterPackageNotFound

Structure = type("Structure", (), {})
Molecule = type("Molecule", (), {})
Composition = type("Composition", (), {})
Lattice = type("Lattice", (), {})
PYMATGEN_NOT_FOUND = "Pymatgen not found, cannot convert structure to a pymatgen Structure or Molecule"


Expand Down Expand Up @@ -78,7 +78,10 @@ def _get_structure(optimade_structure: OptimadeStructure) -> Structure:
attributes = optimade_structure.attributes

return Structure(
lattice=Lattice(attributes.lattice_vectors, attributes.dimension_types),
lattice=Lattice(
attributes.lattice_vectors,
[bool(d) for d in attributes.dimension_types], # type: ignore[union-attr]
),
species=_pymatgen_species(
nsites=attributes.nsites, # type: ignore[arg-type]
species=attributes.species,
Expand Down

0 comments on commit a1a71b9

Please sign in to comment.