Skip to content

Commit

Permalink
Add corner-cases to tests, fix typo exposed by those tests (doesn't a…
Browse files Browse the repository at this point in the history
…ffect XPalm in its current state)
  • Loading branch information
Samuel-amap committed Nov 4, 2024
1 parent 7eb3c95 commit c6895c2
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/dummy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PlantSimEngine.outputs_(::Process1Model) = (var3=-Inf,)
function PlantSimEngine.run!(::Process1Model, models, status, meteo, constants=nothing, extra=nothing)
status.var3 = models.process1.a + status.var1 * status.var2
end
PlantSimEngine.TimeStepDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsTimeStepIndependent()
PlantSimEngine.TimeStepDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsTimeStepDependent()
PlantSimEngine.ObjectDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsObjectIndependent()


Expand Down
33 changes: 33 additions & 0 deletions src/internal_tests_import.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
A sub-module with corner-cases intended to be used for tests, and a dependency graph generator to be used for some randomly seeded tests.
They may be of interest to modelers, or developers willing to tinker with PlantSimEngine.
"""
module InternalTests

using PlantSimEngine, MultiScaleTreeGraph, PlantMeteo, Statistics

outs = Dict(
"E1" => ( :out1,:out),
"E2" => (:out2,),)

#tupl = (1, 2, 3)
#tuple2 = (2, 4)
#outs = Dict{String, Tuple{Vararg{Symbol}}}("1" .=> tupl, "2" => tuple2)
#=outs_ = Dict{String, Vector{Symbol}}()
for i in keys(outs)
outs_[i] = [outs[i]...]
end=#
#outs_ = Dict{String, Vector{Symbol}}(i => Vector(outs[i]...) for i in keys(outs))
outs_ = Dict(i => Vector(outs[i]...) for i in keys(outs))


# Processes:
export

# Models:
export



end
39 changes: 39 additions & 0 deletions src/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,45 @@ julia> (models[:var4],models[:var6])
"""
run!

#todo vector of modellists case
function run2!(
object,
meteo=nothing,
constants=PlantMeteo.Constants(),
extra=nothing;
check=true,
nsteps=nothing,
outputs=nothing,
executor=ThreadedEx()
)
isnothing(nsteps) && (nsteps = get_nsteps(meteo))

default_scale = "Default"

mtg = MultiScaleTreeGraph.Node(MultiScaleTreeGraph.NodeMTG("/", default_scale, 0, 0),)

mapping = Dict(
default_scale => (
SingleModelScale1(),
Status(in = 1.0, in1 = 1.0),
),
)

sim = GraphSimulation(object, mapping, nsteps=nsteps, check=check, outputs=outputs)
run!(
sim,
meteo,
constants,
extra;
check=check,
executor=executor
)

return sim

end


# Managing one or several objects, one or several time-steps:

# This is the default function called by the user, which uses traits
Expand Down

0 comments on commit c6895c2

Please sign in to comment.