ChainRules.jl
ChainRules.jl copied to clipboard
Handle commutativity correctly in scalar rules
Many scalar rules defined on arguments of Number type assume the scalar commutes under multiplication, which fails for non-commutative numbers like quaternions. This PR restricts the type of such rules to Union{Real,Complex}. Where possible, it also adds generic rules defined for Number that don't assume commutativity.
If a user had implemented their own commutative number type that was not a Real, then before this PR, the rules may have worked for them, but now they will not. Hence, this is marked as a breaking change.
This PR requires https://github.com/JuliaDiff/ChainRulesTestUtils.jl/pull/61.
will review tomorrow