Errors#

ExactRef raises an error rather than return an answer it cannot guarantee, and when it is given arguments it cannot use.

exception ReferenceUnavailableError#

A result could not be established with the promised guarantee.

This is raised instead of returning an unverified answer, for example when an exact value may lie exactly on a rounding boundary that the certified algorithm cannot resolve.

exception UnsupportedFormatError#

Raised for an unknown format name or a format this library cannot hold.

ReferenceUnavailableError is a subclass of ArithmeticError. Guarantees and limits lists when it is raised. UnsupportedFormatError is a subclass of ValueError:

Code
import exactref as er

try:
    # er.get_format looks the name up in er.FORMATS, which has no float128
    er.get_format("float128")
except er.UnsupportedFormatError as error:
    # The error's class name and message
    print(f"{type(error).__name__}: {error}")
Output
UnsupportedFormatError: unsupported format 'float128'; supported: ...

Other errors you may meet come from Python's own classes:

Error

When

TypeError

inputs of different dtypes to matmul, an output dtype of another kind, or covers() on a result with several outputs

ValueError

an output for covers() with the wrong dtype or shape, dropout_p other than 0, an unknown overflow mode

OverflowError

an integer that does not fit its format, when converting Python values or with overflow="error"

NotImplementedError

normal() of matrix_exp, matrix_exp_frechet or matrix_exp's backward, which have no normal answer