Skip to content

Commit

Permalink
fix cclib_calculate() wrong err msg claiming to return None when actu…
Browse files Browse the repository at this point in the history
…ally raising
  • Loading branch information
janosh committed Feb 18, 2024
1 parent dbd7e99 commit 3775076
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/atomate2/common/schemas/cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,16 @@ def cclib_calculate(
)

method = method.lower()
cube_methods = ["bader", "ddec6", "hirshfeld"]
cube_methods = ("bader", "ddec6", "hirshfeld")

if method in cube_methods and not cube_file:
raise FileNotFoundError(
f"A cube file must be provided for {method}. Returning None."
)
if method in ["ddec6", "hirshfeld"] and not proatom_dir:
raise FileNotFoundError(f"A cube file must be provided for {method}.")
if method in ("ddec6", "hirshfeld") and not proatom_dir:
if os.getenv("PROATOM_DIR") is None:
raise OSError("PROATOM_DIR environment variable not set. Returning None.")
raise OSError("PROATOM_DIR environment variable not set.")
proatom_dir = os.path.expandvars(os.environ["PROATOM_DIR"])
if proatom_dir and not os.path.exists(proatom_dir):
raise FileNotFoundError(
f"Protatom directory {proatom_dir} does not exist. Returning None."
)
if proatom_dir and not os.path.isdir(proatom_dir):
raise FileNotFoundError(f"{proatom_dir=} does not exist.")

if cube_file and method in cube_methods:
vol = volume.read_from_cube(str(cube_file))
Expand Down

0 comments on commit 3775076

Please sign in to comment.