Skip to content

Commit fc69d37

Browse files
authored
Merge pull request #437 from timholy/teh/getindex
Restrict `getindex` for partials to a single Int
2 parents da034a2 + 799c444 commit fc69d37

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/partials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
@inline Base.length(::Partials{N}) where {N} = N
2121
@inline Base.size(::Partials{N}) where {N} = (N,)
2222

23-
@inline Base.@propagate_inbounds Base.getindex(partials::Partials, I...) = partials.values[I...]
23+
@inline Base.@propagate_inbounds Base.getindex(partials::Partials, i::Int) = partials.values[i]
2424

2525
Base.iterate(partials::Partials) = iterate(partials.values)
2626
Base.iterate(partials::Partials, i) = iterate(partials.values, i)

test/PartialsTest.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,8 @@ for N in (0, 3), T in (Int, Float32, Float64)
135135
end
136136
end
137137

138+
io = IOBuffer()
139+
show(io, MIME("text/plain"), Partials((1, 2, 3)))
140+
@test String(take!(io)) == "3-element ForwardDiff.Partials{3,Int64}:\n 1\n 2\n 3"
141+
138142
end # module

0 commit comments

Comments
 (0)