Skip to content

Commit 36e561c

Browse files
committed
allow getindex to have several indices
1 parent e67f2b0 commit 36e561c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/tangent_types/abstract_zero.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ Base.convert(::Type{T}, x::AbstractZero) where {T<:Number} = zero(T)
2727
(::Type{Complex})(x::AbstractZero, y::Real) = Complex(false, y)
2828
(::Type{Complex})(x::Real, y::AbstractZero) = Complex(x, false)
2929

30-
Base.getindex(z::AbstractZero, k) = z
31-
30+
Base.getindex(z::AbstractZero, ind...) = z
3231
Base.view(z::AbstractZero, ind...) = z
3332
Base.sum(z::AbstractZero; dims=:) = z
3433

test/tangent_types/abstract_zero.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
end
66

77
@testset "Linear operators" begin
8+
@test getindex(ZeroTangent(), 1) === ZeroTangent()
9+
@test getindex(NoTangent(), 1, 2) === NoTangent()
10+
811
@test view(ZeroTangent(), 1) == ZeroTangent()
912
@test view(NoTangent(), 1, 2) == NoTangent()
1013

0 commit comments

Comments
 (0)