@@ -199,7 +199,7 @@ num_us(ils::IndependentlyLinearizedSolution) = length(ils.us)
199
199
Base. size (ils:: IndependentlyLinearizedSolution ) = size (ils. time_mask)
200
200
Base. length (ils:: IndependentlyLinearizedSolution ) = length (ils. ts)
201
201
202
- function finish! (ils:: IndependentlyLinearizedSolution )
202
+ function finish! (ils:: IndependentlyLinearizedSolution{T, S} , return_code) where {T,S}
203
203
function trim_chunk (chunks:: Vector , offset)
204
204
chunks = [chunk for chunk in chunks]
205
205
if eltype (chunks) <: AbstractVector
@@ -216,18 +216,25 @@ function finish!(ils::IndependentlyLinearizedSolution)
216
216
end
217
217
218
218
ilsc = ils. ilsc:: IndependentlyLinearizedSolutionChunks
219
- ts = vcat (trim_chunk (ilsc. t_chunks, ilsc. t_offset)... )
220
- time_mask = hcat (trim_chunk (ilsc. time_masks, ilsc. t_offset)... )
221
- us = [hcat (trim_chunk (ilsc. u_chunks[u_idx], ilsc. u_offsets[u_idx])... )
222
- for u_idx in 1 : length (ilsc. u_chunks)]
219
+ if return_code == ReturnCode. InitialFailure
220
+ # then no (consistent) data to put in, so just put in empty values
221
+ ts = Vector {T} ()
222
+ us = Vector {Matrix{S}} ()
223
+ time_mask = BitMatrix (undef, 0 , 0 )
224
+ else
225
+ ts = vcat (trim_chunk (ilsc. t_chunks, ilsc. t_offset)... )
226
+ time_mask = hcat (trim_chunk (ilsc. time_masks, ilsc. t_offset)... )
227
+ us = [hcat (trim_chunk (ilsc. u_chunks[u_idx], ilsc. u_offsets[u_idx])... )
228
+ for u_idx in 1 : length (ilsc. u_chunks)]
229
+ end
223
230
224
231
# Sanity-check lengths
225
232
if length (ts) != size (time_mask, 2 )
226
233
throw (ArgumentError (" `length(ts)` must equal `size(time_mask, 2)`!" ))
227
234
end
228
235
229
236
# All time masks must start and end with `1`:
230
- if ! all (@view time_mask[:, 1 ]) || ! all (@view time_mask[:, end ])
237
+ if ! isempty (time_mask) && ( ! all (@view time_mask[:, 1 ]) || ! all (@view time_mask[:, end ]) )
231
238
throw (ArgumentError (" Time mask must start and end with 1s!" ))
232
239
end
233
240
0 commit comments