We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7f378c commit 6d1829eCopy full SHA for 6d1829e
src/variables.jl
@@ -213,10 +213,14 @@ creates the array of values in the correct order
213
"""
214
function varmap_to_vars(varmap::AbstractArray{<:Pair},varlist)
215
out = similar(varmap,typeof(last(first(varmap))))
216
- for i in 1:length(varmap)
217
- ivar = varmap[i][1]
+ for (ivar, ival) in varmap
218
j = findfirst(isequal(ivar),varlist)
219
- out[j] = varmap[i][2]
+ if isnothing(j)
+ throw(ArgumentError("Value $(ivar) provided in map not found in $(varlist)"))
220
+ elseif j > length(varmap)
221
+ throw(ArgumentError("Missing value in $(varmap), need $(varlist)"))
222
+ end
223
+ out[j] = ival
224
end
225
226
# Make output match varmap in type and shape
0 commit comments