Skip to content

Commit

Permalink
BUG: Fix the _read_basis exception handler raising an IndexError
Browse files Browse the repository at this point in the history
…if the list of basis set names is too short
  • Loading branch information
Bas van Beek committed Feb 11, 2022
1 parent 91b3863 commit ce8df34
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/qmflows/parsers/_cp2k_basis_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
_Basis2Tuple = Tuple[List[AtomBasisKey], List[AtomBasisData]]


class _BasisFileIter:
class _BasisFileIter(Iterator[str]):
"""Enumerate through the passed ``iterable`` and remove all empty and commented lines."""

__slots__ = ("__weakref__", "_enumerator", "_name", "_index")
Expand Down Expand Up @@ -71,9 +71,8 @@ def _read_basis(f: _BasisFileIter) -> _Basis2Tuple:
keys.append(AtomBasisKey(atom, basis, basis_fmt))
values.append(AtomBasisData(exp, coef))
except Exception as ex:
raise ValueError(
f'Failed to parse the basis set "{atom} {basis_list[0]}" on line {f.index}'
) from ex
basis = f"{atom} {basis_list[0]}" if len(basis_list) > 0 else atom
raise ValueError(f'Failed to parse the {basis!r} basis set on line {f.index}') from ex
return keys, values


Expand Down

0 comments on commit ce8df34

Please sign in to comment.