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

Implement getindex and view for AbstractZero

Open sethaxen opened this issue 5 years ago • 2 comments

It would be handy to add something like the following overloads:

getindex(x::AbstractZero, i..) = x
view(x::AbstractZero, i...) = x

since a Zero if interpreted as an array can only have Zero subarrays or elements. This would make it so rules that depend only on certain elements of a differential don't necessarily have to special-case to work around possible Zero arrays but can instead just index them as normal.

sethaxen avatar Dec 24 '20 01:12 sethaxen

Agreed. Also getproperty so it can pretend to be a struct.

oxinabox avatar Dec 24 '20 01:12 oxinabox

Maybe also get so it can pretend to be something with keys?

sethaxen avatar Dec 24 '20 02:12 sethaxen