API

Modules

Types and constants

Functions and macros

Documentation

CheckedCalls.ReturnValueContainsNaNType
struct ReturnValueContainsNaN <: Exception

Exception to be thrown if the return value r of a function f is or contains a NaN value when called with arguments args.

Constructors:

ReturnValueContainsNaN(r, f, args)
ReturnValueContainsNaN(r, f, args, cause)

cause is missing by default, but should may be set to anything that indicates the cause of the NaN value, including another ReturnValueContainsNaN instance that was encountered while computing f(args...).

CheckedCalls.checkedcallFunction
checkedcall(f, args...)
checkedcall(f)

Calls f(args...), checks the result for abnormalities, and either returns the result or throws an exception.

checkedcall(f)(args...) is equivalent to checkedcall(f, args...).

By default, checks the return value with containsnan.

checkedcall should be specialized if the underlying cause of the abnormality can be determined more precisely without undue computational overhead. For example for

chained(f, g, x) = f(g(x))

One may want to specialize

function checkedcall(::typeof(chained), f, g, x)
    checkedcall(f, checkedcall(g, x))
end

checkedcall may also be specialized to perform additional output (and input) value checks for specific functions, checks do not need to be limited to NaN values.

CheckedCalls.containsnanFunction
containsnan(x)::Bool

Checks if x definitely is or contains a NaN value.

Returns false if containsnan is not defined for the type of x and should also return false if checking x would be computationally expensive.

CheckedCalls.throw_if_containsnanMethod
throw_if_containsnan(r, f, args)

Utility function that checks if a value r, assumed to be the result of f(args...), contains NaN values and if so, throws an ReturnValueContainsNaN exception.

throw_if_containsnan comes with an specialized ChainRulesCore.rrule to avoid computational overhead during automatic differentiation.