Skip to content

Commit

Permalink
Fix typing lint, typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
Balandat committed Dec 29, 2022
1 parent fb580d1 commit 35dabe0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pyro/ops/integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Registry for exception handlers that can be used to catch certain failures
# during computation of `potential_fn` within `potential_grad`.
_EXCEPTION_HANDLERS = {}
_EXCEPTION_HANDLERS: Dict[str, Callable[[Exception], bool]] = {}


def velocity_verlet(
Expand Down Expand Up @@ -102,9 +102,9 @@ def register_exception_handler(
:param name: name of the handler (must be unique).
:param handler: A callable mapping an exception to a boolean. Exceptions
that evaluate to true in any of the handlers are handled in teh computation
that evaluate to true in any of the handlers are handled in the computation
of the potential energy.
:param overwrite: If True, overwrite handlers already registerd under the
:param overwrite: If True, overwrite handlers already registered under the
provided name.
"""
if name in _EXCEPTION_HANDLERS and not overwrite:
Expand All @@ -118,9 +118,8 @@ def register_exception_handler(
def _handle_torch_singular(exception: Exception) -> bool:
"""Exception handler for errors thrown on (numerically) singular matrices."""
if type(exception) == RuntimeError:
return "singular" in str(exception) or "input is not positive-definite" in str(
exception
)
msg = str(exception)
return "singular" in msg or "input is not positive-definite" in msg
return False


Expand Down

0 comments on commit 35dabe0

Please sign in to comment.