calliope-project / calliope

A multi-scale energy systems modelling framework
https://www.callio.pe
Apache License 2.0
287 stars 93 forks source link

Decision vars & global exprs in where strings #490

Closed brynpickering closed 11 months ago

brynpickering commented 11 months ago

Fixes issue(s) #450

Summary of changes in this pull request:

Since there is a strict order of things in the backend (parameters -> variables -> expressions -> constraints -> objective), we will have already constructed variables by the time we construct expressions and will have access to both variables and expressions by the time we reach constraints. Therefore, their existence can be checked in the constraint/objective where string. It makes some things less verbose.

Reviewer checklist:

codecov[bot] commented 11 months ago

Codecov Report

Merging #490 (94a64e1) into main (cbed4c8) will decrease coverage by 2.79%. Report is 4 commits behind head on main. The diff coverage is 95.81%.

@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
- Coverage   94.98%   92.20%   -2.79%     
==========================================
  Files          31       32       +1     
  Lines        3890     4015     +125     
  Branches        0      961     +961     
==========================================
+ Hits         3695     3702       +7     
- Misses        195      196       +1     
- Partials        0      117     +117     
Files Coverage Δ
src/calliope/__init__.py 100.00% <ø> (ø)
src/calliope/_version.py 100.00% <ø> (ø)
src/calliope/backend/helper_functions.py 99.35% <ø> (ø)
src/calliope/backend/where_parser.py 98.55% <100.00%> (ø)
src/calliope/cli.py 81.67% <100.00%> (ø)
src/calliope/core/__init__.py 100.00% <ø> (ø)
src/calliope/core/attrdict.py 99.50% <ø> (ø)
src/calliope/core/io.py 91.75% <ø> (ø)
src/calliope/core/model.py 93.23% <100.00%> (ø)
src/calliope/core/util/generate_runs.py 87.09% <ø> (ø)
... and 22 more