Skip to content

Commit

Permalink
Merge pull request #18 from zincware/update4dev
Browse files Browse the repository at this point in the history
add check atoms are provided to node
  • Loading branch information
MrJulEnergy committed Mar 2, 2023
2 parents 4d1e096 + 1403062 commit 13e3f1e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions znlib/nodes/cp2k_single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ class CP2KSinglePoint(Node):
output_file = dvc.outs(utils.nwd / "atoms.extxyz")
cp2k_directory = dvc.outs(utils.nwd / "cp2k")

def _post_init_(self):
# Check if atoms were provided:
if self.atoms is None and self.atoms_file is None:
raise TypeError("Both atoms and atoms_file mustn't be None")
if self.atoms is not None and self.atoms_file is not None:
raise TypeError(
"Atoms and atoms_file are mutually exclusive. Please only provide one"
)

def run(self):
"""ZnTrack run method."""
# read atoms from file, if file path is provided
if self.atoms_file is not None:
self.atoms = list(ase.io.iread(self.atoms_file))

Expand Down

0 comments on commit 13e3f1e

Please sign in to comment.