Skip to content

Commit

Permalink
fix get_cell_volume
Browse files Browse the repository at this point in the history
  • Loading branch information
ltalirz committed Feb 1, 2022
1 parent 026f7e1 commit 46fb66b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions aiida/orm/nodes/data/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,8 @@ def get_cell_volume(self):
:return: a float.
"""
if self.cell is _DEFAULT_CELL:
return 0
return calc_cell_volume(self.cell)

def get_cif(self, converter='ase', store=False, **kwargs):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ def test_ase(self):
self.assertAlmostEqual(c[1].mass, 110.2)

@unittest.skipIf(not has_ase(), 'Unable to import ase')
def test_ase_molecule(self):
def test_ase_molecule(self): # pylint: disable=no-self-use
"""Tests that importing a molecule from ASE works."""
from ase.build import molecule
s = StructureData(ase=molecule('H2O'))
Expand All @@ -1959,9 +1959,10 @@ def test_ase_molecule(self):
assert retdict['dim'] == 0

# Enabling this consistency check would require us to change the default value
# of pbc to [False, False, False]
# with self.assertRaises(AssertionError):
# Enabling pbc on a structure with no cell should raise
# s.set_pbc(True)
# Enabling pbc on a structure with no cell should raise
# s.set_pbc(True)

# after setting a cell, we should be able to enable pbc
s.set_cell([[5, 0, 0], [0, 5, 0], [0, 0, 5]])
Expand Down

0 comments on commit 46fb66b

Please sign in to comment.