Skip to content

Commit c6895c2

Browse files
committed
Add corner-cases to tests, fix typo exposed by those tests (doesn't affect XPalm in its current state)
1 parent 7eb3c95 commit c6895c2

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

examples/dummy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PlantSimEngine.outputs_(::Process1Model) = (var3=-Inf,)
1818
function PlantSimEngine.run!(::Process1Model, models, status, meteo, constants=nothing, extra=nothing)
1919
status.var3 = models.process1.a + status.var1 * status.var2
2020
end
21-
PlantSimEngine.TimeStepDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsTimeStepIndependent()
21+
PlantSimEngine.TimeStepDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsTimeStepDependent()
2222
PlantSimEngine.ObjectDependencyTrait(::Type{<:Process1Model}) = PlantSimEngine.IsObjectIndependent()
2323

2424

src/internal_tests_import.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
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.
3+
They may be of interest to modelers, or developers willing to tinker with PlantSimEngine.
4+
5+
"""
6+
module InternalTests
7+
8+
using PlantSimEngine, MultiScaleTreeGraph, PlantMeteo, Statistics
9+
10+
outs = Dict(
11+
"E1" => ( :out1,:out),
12+
"E2" => (:out2,),)
13+
14+
#tupl = (1, 2, 3)
15+
#tuple2 = (2, 4)
16+
#outs = Dict{String, Tuple{Vararg{Symbol}}}("1" .=> tupl, "2" => tuple2)
17+
#=outs_ = Dict{String, Vector{Symbol}}()
18+
for i in keys(outs)
19+
outs_[i] = [outs[i]...]
20+
end=#
21+
#outs_ = Dict{String, Vector{Symbol}}(i => Vector(outs[i]...) for i in keys(outs))
22+
outs_ = Dict(i => Vector(outs[i]...) for i in keys(outs))
23+
24+
25+
# Processes:
26+
export
27+
28+
# Models:
29+
export
30+
31+
32+
33+
end

src/run.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,45 @@ julia> (models[:var4],models[:var6])
8686
"""
8787
run!
8888

89+
#todo vector of modellists case
90+
function run2!(
91+
object,
92+
meteo=nothing,
93+
constants=PlantMeteo.Constants(),
94+
extra=nothing;
95+
check=true,
96+
nsteps=nothing,
97+
outputs=nothing,
98+
executor=ThreadedEx()
99+
)
100+
isnothing(nsteps) && (nsteps = get_nsteps(meteo))
101+
102+
default_scale = "Default"
103+
104+
mtg = MultiScaleTreeGraph.Node(MultiScaleTreeGraph.NodeMTG("/", default_scale, 0, 0),)
105+
106+
mapping = Dict(
107+
default_scale => (
108+
SingleModelScale1(),
109+
Status(in = 1.0, in1 = 1.0),
110+
),
111+
)
112+
113+
sim = GraphSimulation(object, mapping, nsteps=nsteps, check=check, outputs=outputs)
114+
run!(
115+
sim,
116+
meteo,
117+
constants,
118+
extra;
119+
check=check,
120+
executor=executor
121+
)
122+
123+
return sim
124+
125+
end
126+
127+
89128
# Managing one or several objects, one or several time-steps:
90129

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

0 commit comments

Comments
 (0)