Skip to content

Commit a536bd1

Browse files
authored
Add a new method of getindex (#1502)
* Added a new method of getindex for an OffsetVector of tracedRNumber and tracedRArray and Base.oneto * Updated new getindex call * Reverting method handle
1 parent c5dc80c commit a536bd1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/ReactantOffsetArraysExt.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ function Base.getindex(
4444
return getindex(parent(x), offset_indices)
4545
end
4646

47+
function Base.getindex(
48+
x::OffsetVector{Reactant.TracedRNumber{T}, Reactant.TracedRArray{T, 1}}, indices::Base.OneTo{Int}
49+
) where {T}
50+
offset_indices = indices .- x.offsets[1]
51+
return getindex(parent(x), offset_indices)
52+
end
53+
4754
parentindex(r::OffsetArrays.IdOffsetRange, i) = i .- r.offset
4855
function Base.getindex(
4956
a::OffsetArray{<:Reactant.TracedRNumber,N}, indices::Vararg{Union{Int,AbstractArray},N}

0 commit comments

Comments
 (0)