diff --git a/src/tangent_types/abstract_zero.jl b/src/tangent_types/abstract_zero.jl index 881386e88..c1222fb9f 100644 --- a/src/tangent_types/abstract_zero.jl +++ b/src/tangent_types/abstract_zero.jl @@ -27,8 +27,7 @@ Base.convert(::Type{T}, x::AbstractZero) where {T<:Number} = zero(T) (::Type{Complex})(x::AbstractZero, y::Real) = Complex(false, y) (::Type{Complex})(x::Real, y::AbstractZero) = Complex(x, false) -Base.getindex(z::AbstractZero, k) = z - +Base.getindex(z::AbstractZero, ind...) = z Base.view(z::AbstractZero, ind...) = z Base.sum(z::AbstractZero; dims=:) = z diff --git a/test/tangent_types/abstract_zero.jl b/test/tangent_types/abstract_zero.jl index 126ddc97d..67535dad9 100644 --- a/test/tangent_types/abstract_zero.jl +++ b/test/tangent_types/abstract_zero.jl @@ -5,6 +5,9 @@ end @testset "Linear operators" begin + @test getindex(ZeroTangent(), 1) === ZeroTangent() + @test getindex(NoTangent(), 1, 2) === NoTangent() + @test view(ZeroTangent(), 1) == ZeroTangent() @test view(NoTangent(), 1, 2) == NoTangent()