The ScenarioLoader Module
GenFSM.ScenarioLoader
— ModuleGenFSM_simrep
Simulation settings repository for GenFSM models.
This package sole function is load_settings
.
The settings are stored in this repository as yaml files in:
- [project]
- scenarios
- [scenario]
- scenarios
Where the default project and the default scenarios ae both named "default".
Module Index
GenFSM.ScenarioLoader.expand_dict
GenFSM.ScenarioLoader.load_general_settings
GenFSM.ScenarioLoader.override_nested_dict!
GenFSM.ScenarioLoader.recursive_replace!
Detailed API
GenFSM.ScenarioLoader.expand_dict
— Methodexpand_dict(d::Dict)
Expand dictionary keys that are tuples into nested dictionaries.
Example
d_input = Dict(("a","b","c") => 10, "e" => 30, ("a","b","d") => 20)
d_output = expand_dict(d_input) # Dict("a" => Dict("b" => Dict("c" => 10, "d" => 20)), "e" => 30)
GenFSM.ScenarioLoader.load_general_settings
— Functionload_general_settings(project="default",scenario="default")
Load the settings for a specific project and scenario. The settings are returned as a dictionary.
GenFSM.ScenarioLoader.override_nested_dict!
— Methodoverride_nested_dict!(d1::AbstractDict, d2::AbstractDict; strict::Bool=true, expand=true)
Override the values in the dictionary d1
with the values in the dictionary d2
.
d2 can be either another nested dictionary or a dictionary where the different levels are represented as tuple keys, e.g. d2 = Dict("a"=>Dict("b"=>1))
or d2 = Dict(("a","b")=>1)
. If d2 has new keys and strict
is enabled, an error is raised.
GenFSM.ScenarioLoader.recursive_replace!
— Methodrecursive_replace!(dict,replacement_pattern)
Replace a pattern in the values a possibly nested dictionary
d = Dict("a" => Dict(1 => "aaa", 2 => "bgggb"), 3=>"ccc")
recursive_replace!(d,"ggg" => "GGG") # Dict("a" => Dict(1 => "aaa", 2 => "bGGGb"), 3=>"ccc")