Skip to content

Commit 3a3cf01

Browse files
authored
Merge branch 'master' into mcs-perf
2 parents fe217a3 + 1bebba9 commit 3a3cf01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/time_arrays.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ function Base.getindex(v::TimestepVector, ts::VariableTimestep{TIMES}) where {TI
171171
end
172172

173173
function Base.getindex(v::TimestepVector{FixedTimestep{FIRST, STEP, LAST}, T_data}, ts::TimestepValue{T_time}) where {T_data, FIRST, STEP, LAST, T_time}
174-
t = _get_time_value_position([FIRST:STEP:LAST...], ts)
174+
t, remainder = divrem(ts.value - FIRST, STEP)
175+
remainder==0 || error("Invalid index.")
176+
177+
t += ts.offset + 1
178+
179+
0 < t <= length(FIRST:STEP:LAST) || error("Invalid index.")
180+
175181
v.data isa SubArray ? view_offset = v.data.offset1 : view_offset = 0
176182
t = t - view_offset
177183
data = v.data[t]

0 commit comments

Comments
 (0)