Skip to content

Commit

Permalink
Better printing of the type promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
VEZY committed Apr 3, 2024
1 parent 9e7af97 commit dba0672
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mtg/initialisation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ function init_node_status!(node, statuses, mapped_vars, reverse_multiscale_mappi
else
node_var =
try
promoted_var = []
promoted_var_type = []
for (subtype, newtype) in type_promotion
if isa(node[var], subtype)
@warn "Promoting `$(var)` value taken from MTG node $(node_id(node)) ($(symbol(node))) from $subtype to $newtype: $promoted_var ($(typeof(promoted_var)))" maxlog = 5
push!(promoted_var, convert(newtype, node[var]))
converted_var = convert(newtype, node[var])
@warn "Promoting `$(var)` value taken from MTG node $(node_id(node)) ($(symbol(node))) from $subtype to $newtype: $converted_var ($(typeof(converted_var)))" maxlog = 5
push!(promoted_var_type, converted_var)
end
end
length(promoted_var) > 0 ? promoted_var[1] : node[var]
length(promoted_var_type) > 0 ? promoted_var_type[1] : node[var]
catch e
error("Failed to convert variable `$(var)` in MTG node $(node_id(node)) ($(symbol(node))) from type `$(typeof(node[var]))` to type `$(eltype(st_template[var]))`: $(e)")
end
Expand Down

0 comments on commit dba0672

Please sign in to comment.