@@ -127,6 +127,59 @@ function _get_ts_indices(ts_array::Array{TimestepValue{T}, 1}, times::Union{Tupl
127
127
return [_get_time_value_position (times, ts) for ts in ts_array]
128
128
end
129
129
130
+ # Base.firstindex and Base.lastindex
131
+ function Base. firstindex (arr:: TimestepArray{T_TS, T, N, ti} ) where {T_TS, T, N, ti}
132
+ if ti == 1
133
+ return Mimi. TimestepIndex (1 )
134
+ else
135
+ return 1
136
+ end
137
+ end
138
+
139
+ function Base. lastindex (arr:: TimestepArray{T_TS, T, N, ti} ) where {T_TS, T, N, ti}
140
+ if ti == length (size (arr. data))
141
+ return Mimi. TimestepIndex (length (arr. data))
142
+ else
143
+ return length (arr. data)
144
+ end
145
+ end
146
+
147
+ function Base. lastindex (arr:: TimestepArray{T_TS, T, N, ti} , dim:: Int ) where {T_TS, T, N, ti}
148
+ if ti == dim
149
+ return Mimi. TimestepIndex (size (arr. data, dim))
150
+ else
151
+ return size (arr. data, dim)
152
+ end
153
+ end
154
+
155
+ function Base. firstindex (arr:: TimestepArray{T_TS, T, N, ti} , dim:: Int ) where {T_TS, T, N, ti}
156
+ if ti == dim
157
+ return Mimi. TimestepIndex (1 )
158
+ else
159
+ return 1
160
+ end
161
+ end
162
+
163
+ # add axes methos copied from abstarctarray.jl:56
164
+ function Base. axes (A:: TimestepArray{T_TS, T, N, ti} , d:: Int ) where {T_TS, T, N, ti}
165
+ _d_lessthan_N = d <= N;
166
+ if d == ti
167
+ if _d_lessthan_N
168
+ return Tuple (TimestepIndex .(1 : size (A,d)))
169
+ else
170
+ return TimestepIndex (1 )
171
+ end
172
+ else
173
+ if _d_lessthan_N
174
+ if _d_lessthan_N
175
+ return 1 : size (A,d)
176
+ else
177
+ return 1
178
+ end
179
+ end
180
+ end
181
+ end
182
+
130
183
#
131
184
# b. TimestepVector
132
185
#
@@ -233,8 +286,6 @@ function Base.length(v::TimestepVector)
233
286
return length (v. data)
234
287
end
235
288
236
- Base. lastindex (v:: TimestepVector ) = length (v)
237
-
238
289
#
239
290
# c. TimestepMatrix
240
291
#
@@ -267,7 +318,6 @@ function Base.getindex(mat::TimestepMatrix{FixedTimestep{FIRST, STEP}, T, 2}, id
267
318
end
268
319
269
320
function Base. getindex (mat:: TimestepMatrix{VariableTimestep{TIMES}, T, 2} , idx:: AnyIndex , ts:: VariableTimestep{TIMES} ) where {T, TIMES}
270
- # WAS THIS: data = mat.data[ts.t, idx, ts.t]
271
321
data = mat. data[idx, ts. t]
272
322
_missing_data_check (data, ts. t)
273
323
end
0 commit comments