Skip to content

Commit 6e1ffaa

Browse files
author
Alexey Stukalov
committed
prepare_start_params(): tighten type check
1 parent 9c516fd commit 6e1ffaa

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/optimizer/abstract.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,24 @@ function prepare_start_params(start_val::AbstractVector, model::AbstractSem; kwa
154154
"The length of `start_val` vector ($(length(start_val))) does not match the number of model parameters ($(nparams(model))).",
155155
),
156156
)
157+
(eltype(start_val) <: Number) || throw(
158+
TypeError(
159+
:prepare_start_params,
160+
"start_val elements must be numeric",
161+
Number,
162+
eltype(start_val),
163+
),
164+
)
157165
return start_val
158166
end
159167

160168
function prepare_start_params(start_val::AbstractDict, model::AbstractSem; kwargs...)
161-
return [start_val[param] for param in params(model)] # convert to a vector
169+
# convert to a vector
170+
return prepare_start_params(
171+
[start_val[param] for param in params(model)],
172+
model;
173+
kwargs...,
174+
)
162175
end
163176

164177
# get from the ParameterTable (potentially from a different model with match param names)

0 commit comments

Comments
 (0)