-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Trying to map a variable to the previous timestep of another variable at the same scale yields the following error :
ERROR: AssertionError: Variable `in_day_summed_prev_timestep` is mapped to its own scale in organ Default. This is not allowed.
Here's a minimal example to reproduce the error, with a model that simply increments, and the other that passes the result without changing it :
PlantSimEngine.@process "ToyAdd1" verbose = false
struct MyToyAdd1Model <: AbstractToyadd1Model end
PlantSimEngine.inputs_(m::MyToyAdd1Model) = (in_summed_prev_timestep=-Inf,)
PlantSimEngine.outputs_(m::MyToyAdd1Model) = (out_summed=-Inf,)
function PlantSimEngine.run!(m::MyToyAdd1Model, models, status, meteo, constants=nothing, extra=nothing)
status.out_summed = meteo.data + status.in_summed_prev_timestep
end
PlantSimEngine.@process "ToyNoop" verbose = false
struct MyToyNoopModel <: AbstractToynoopModel end
PlantSimEngine.inputs_(m::MyToyNoopModel) = (out_summed=-Inf,)
PlantSimEngine.outputs_(m::MyToyNoopModel) = (out_summed_2= -Inf,)
function PlantSimEngine.run!(m::MyToyNoopModel, models, status, meteo, constants=nothing, extra=nothing)
status.out_summed_2 = status.out_summed
end
mapping = Dict(
"Default"=> (
MultiScaleModel(
model=MyToyAdd1Model(),
mapped_variables=[
PlantSimEngine.PreviousTimeStep(:in_summed_prev_timestep) => "Default" => :out_summed_2,
]),
MyToyNoopModel(),
Status(in_summed_prev_timestep=0,out_summed_2=0,)
),
)
mtg = Node(MultiScaleTreeGraph.NodeMTG("/", "Default", 1, 1))
df = DataFrame(:data => [1 for i in 1:365], )
out = run!(mtg, mapping, df)If one replaces
PlantSimEngine.PreviousTimeStep(:in_summed_prev_timestep) => "Default" => :out_summed_2,with
PlantSimEngine.PreviousTimeStep(:in_summed_prev_timestep) => :out_summed_2,Then there are no issues.
Reasonable choices that come to mind : we can keep the behaviour as is, but change the error message to indicate the expected API usage (and warn 'are you sure you intended to map to the same scale ?'), or change the behaviour to fully allow that syntax.
In any case, there is a problem with the error message.
Metadata
Metadata
Assignees
Labels
No labels