Skip to content

Commit

Permalink
Adding ImportErrror into the to_atomisticmethod.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikibonacci committed Nov 19, 2024
1 parent be46122 commit 0af4b2b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/aiida/orm/nodes/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,13 @@ def to_atomistic(self):
"""
Returns the atomistic StructureData version of the orm.StructureData one.
"""
from aiida_atomistic import StructureDataMutable as AtomisticStructureDataMutable
try:
from aiida_atomistic import StructureData as AtomisticStructureData
from aiida_atomistic import StructureDataMutable as AtomisticStructureDataMutable
except ImportError:
raise ImportError('aiida-atomistic plugin is not installed, \
please install it to have full support for atomistic structures')

atomistic = AtomisticStructureDataMutable(pbc=self.pbc, cell=self.cell)
for site in self.sites:
atomistic.add_atom(
Expand All @@ -785,7 +791,7 @@ def to_atomistic(self):
}
)

return atomistic.to_immutable()
return AtomisticStructureData.from_mutable(atomistic)

def get_dimensionality(self):
"""Return the dimensionality of the structure and its length/surface/volume.
Expand Down

0 comments on commit 0af4b2b

Please sign in to comment.