API
Modules
Types and constants
Functions and macros
Documentation
CheckedCalls.CheckedCalls — ModuleCheckedCallsFunction calls with additional checks.
CheckedCalls.CheckedFunction — Typestruct CheckedFunction{F}Default return value of checkedcall(f).
Do not instantiate this type directly, use checkedcall(f) instead.
CheckedCalls.ReturnValueContainsNaN — Typestruct ReturnValueContainsNaN <: ExceptionException 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.checkedcall — Functioncheckedcall(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))
endcheckedcall 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.containsnan — Functioncontainsnan(x)::BoolChecks 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_containsnan — Methodthrow_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.