Skip to content

Commit

Permalink
fix pymatgen test
Browse files Browse the repository at this point in the history
  • Loading branch information
ltalirz committed Feb 1, 2022
1 parent 46fb66b commit b190ecc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aiida/orm/nodes/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import copy
import functools
import itertools
from sqlite3 import ProgrammingError

from aiida.common.constants import elements
from aiida.common.exceptions import UnsupportedSpeciesError
Expand Down Expand Up @@ -793,7 +792,7 @@ def get_dimensionality(self):
retdict['label'] = self._dimensionality_label[dim]

if dim not in (0, 1, 2, 3):
raise ProgrammingError(f'Dimensionality {dim} must be one of 0, 1, 2, 3')
raise ValueError(f'Dimensionality {dim} must be one of 0, 1, 2, 3')

if self.cell == _DEFAULT_CELL:
# If no cell was specified, no volume can be computed
Expand Down Expand Up @@ -1845,6 +1844,8 @@ def _get_object_pymatgen_structure(self, **kwargs):

if self.pbc != (True, True, True):
raise ValueError('Periodic boundary conditions must apply in all three dimensions of real space')
if self.cell == _DEFAULT_CELL:
raise ValueError('Must specify cell in order to create pymatgen structure')

species = []
additional_kwargs = {}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,11 @@ class TestPymatgenFromStructureData(AiidaTestCase):
def test_1(self):
"""Tests the check of periodic boundary conditions."""
struct = StructureData()
with self.assertRaises(ValueError):
# cell needed for pymatgen structure
struct.get_pymatgen_structure()

struct.set_cell([[1, 0, 0], [0, 1, 2], [3, 4, 5]])
struct.pbc = [True, True, True]
struct.get_pymatgen_structure()

Expand Down

0 comments on commit b190ecc

Please sign in to comment.