Skip to content

Commit b5e20d5

Browse files
committed
fixed vector_getranges when vns are not found
1 parent 5e89f95 commit b5e20d5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/varinfo.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ function vector_getranges(varinfo::TypedVarInfo, vns::Vector{<:VarName})
674674
offsets = cumsum(map(vector_length, metadatas))
675675
# Extract the ranges from each metadata.
676676
ranges = Vector{UnitRange{Int}}(undef, length(vns))
677+
# Need to keep track of which ones we've seen.
678+
not_seen = fill(true, length(vns))
677679
for (i, metadata) in enumerate(metadatas)
678680
vns_metadata = filter(Base.Fix1(haskey, metadata), vns)
679681
# If none of the variables exist in the metadata, we return an empty array.
@@ -686,13 +688,14 @@ function vector_getranges(varinfo::TypedVarInfo, vns::Vector{<:VarName})
686688
# NOTE: There might be duplicates in `vns`, so we need to handle that.
687689
indices = findall(==(vn), vns)
688690
for idx in indices
691+
not_seen[idx] = false
689692
ranges[idx] = r_vn .+ offset
690693
end
691694
end
692695
end
693696
# Raise key error if any of the variables were not found.
694-
if any(!isassigned, ranges)
695-
inds = findall(!isassigned, ranges)
697+
if any(not_seen)
698+
inds = findall(not_seen)
696699
# Just use a `convert` to get the same type as the input; don't want to confuse by overly
697700
# specilizing the types in the error message.
698701
throw(KeyError(convert(typeof(vns), vns[inds])))

0 commit comments

Comments
 (0)