ChainRulesTestUtils.jl
ChainRulesTestUtils.jl copied to clipboard
Test functions with constraints on arguments
Related to https://github.com/JuliaDiff/FiniteDifferences.jl/issues/52, it seems there is currently no way to specify constraints on function arguments to FiniteDifferences. For instance, when testing the ChainRule adjoint of (an extension of) binomlogpdf(n, p, x) input p has to be constrained to the interval [0, 1] since otherwise the forward pass errors.
In DistributionsAD we introduced a custom way to specify mappings from R^n to the desired subspace to avoid these issues in our tests (see, e.g., https://github.com/TuringLang/DistributionsAD.jl/blob/d5a479acc90acd9fe42f1abd207788c164ac85af/test/ad/distributions.jl#L252)