ChainRules.jl icon indicating copy to clipboard operation
ChainRules.jl copied to clipboard

Handle commutativity correctly in scalar rules

Open sethaxen opened this issue 5 years ago • 1 comments

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.

sethaxen avatar Oct 07 '20 05:10 sethaxen

will review tomorrow

oxinabox avatar Oct 07 '20 10:10 oxinabox