Skip to content

Commit

Permalink
Merge pull request #15 from ait-energy/dev
Browse files Browse the repository at this point in the history
fix: <self> reference in dynamic template building
  • Loading branch information
sstroemer authored Sep 6, 2024
2 parents 0b4840a + 47e8b53 commit e2006d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions docs/src/pages/tutorials/creating_new_components/templates_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,12 @@ functions:
prepare: |
# Determine if investment should be enabled, and set the parameter (used to enable `decision`).
invest = !isnothing(get("p_nom_max")) && get("p_nom_max") > get("p_nom")
set("_invest", invest)
self = get("self")
set("_invest", invest)
if invest
# Set the capacity to the size of the decision variable.
set("_capacity", "<self>.decision:value")
set("_capacity", "$(self).decision:value")
else
# Set the capacity to the value of `p_nom`.
set("_capacity", get("p_nom"))
Expand Down Expand Up @@ -406,11 +407,12 @@ To be added.
prepare: |
# Determine if investment should be enabled, and set the parameter (used to enable `decision`).
invest = !isnothing(get("p_nom_max")) && get("p_nom_max") > get("p_nom")
set("_invest", invest)
self = get("self")
set("_invest", invest)
if invest
# Set the capacity to the size of the decision variable.
set("_capacity", "<self>.decision:value")
set("_capacity", "$(self).decision:value")
else
# Set the capacity to the value of `p_nom`.
set("_capacity", get("p_nom"))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function _new_metafmt(level::LogLevel, _module, group, id, file, line)
elseif depth[1] == "addons"
depth_prefix = "addon ($(replace(depth[end], ".jl" => "")))"
else
depth_prefix = "unknown ($(replace(depth[end], ".jl" => "")))"
depth_prefix = "? ($(replace(depth[end], ".jl" => "")))"
end
else
depth = splitpath(file)
Expand Down

0 comments on commit e2006d4

Please sign in to comment.