Skip to content

doc: create rules overview for SB and CBA rules - #761

Merged
lisazeyen merged 15 commits into
masterfrom
doc/document-tyndp-rules
Jul 20, 2026
Merged

doc: create rules overview for SB and CBA rules#761
lisazeyen merged 15 commits into
masterfrom
doc/document-tyndp-rules

Conversation

@tgilon

@tgilon tgilon commented Jun 23, 2026

Copy link
Copy Markdown
Member

Closes # (if applicable).

Changes proposed in this Pull Request

Extends #759 and follow-up of #754. This PR creates rules overview for all SB and CBA rules. This PR also suggests to disable root TOC entries in order to declutter the table of contents for the rules overview (contributed upstream in PyPSA#2216).

Preview of the changes: https://open-tyndp--761.org.readthedocs.build/en/761/sb_rules/

image

Tasks

Workflow

Open issues

Notes

Generative AI was used to assist with code generation and review. All content has been reviewed, verified, and is the responsibility of the author.

Checklist

  • Security scan(s) show no high-severity bugs, critical vulnerabilities, or exposed secrets.
  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to pixi.toml (using pixi add <dependency-name>).
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • Changes in configuration options are added in config/test/*.yaml.
  • The multiple weather/climate years test is passing locally (using pixi run -e open-tyndp tyndp-cyears-test).
  • Open-TYNDP SPDX license header added to all touched files.
  • For new data sources or versions, these instructions have been followed.
  • New rules are documented in the appropriate doc/*.rst files.
  • A release note doc/release_notes.rst is added.
  • Major features are documented with up-to-date information in doc/index.rst.
  • Module docstrings added to new Python scripts.

@tgilon tgilon added this to the Release v0.8 milestone Jun 23, 2026
@tgilon
tgilon requested a review from willu47 June 23, 2026 10:15
@tgilon tgilon self-assigned this Jun 23, 2026
@tgilon tgilon added SB Scenario Building CBA Cost Benefit Analysis labels Jun 23, 2026
@lisazeyen
lisazeyen self-requested a review July 9, 2026 11:51
Base automatically changed from doc/format-docstrings to master July 9, 2026 12:03

@lisazeyen lisazeyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks a lot @tgilon for preparing!

I mainly have comments about the grouping of the rules and made some suggestions plus two minor comments (typo + missing returns in a function).

Comment thread doc/sb_rules.md Outdated
Comment thread doc/cba_rules.md Outdated
Comment thread doc/cba_rules.md Outdated
Comment thread scripts/cba/solve_cba_network.py
Comment thread scripts/prepare_sector_network.py Outdated
Comment on lines 229 to -236
@@ -233,11 +193,6 @@ def optimize_with_rolling_horizon(
retry_kwargs["solver_name"] = fallback_solver["name"]
retry_kwargs["solver_options"] = fallback_solver.get("options", {})
status, condition = n.optimize(sns, **retry_kwargs) # type: ignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is just about the docstring of this function def solve_network it seems to remove the description on Returns

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any diff with master (see master code here).

def solve_network(
n: pypsa.Network,
config: dict,
params: dict,
solving: dict,
planning_horizons: str | None = None,
**kwargs,
) -> None:
"""
Solve network optimization problem.
Parameters
----------
n : pypsa.Network
The PyPSA network instance.
config : dict
Configuration dictionary containing solver settings.
params : dict
Dictionary of solving parameters.
solving : dict
Dictionary of solving options and configuration.
planning_horizons : str or None, optional
The current planning horizon year or None in perfect foresight.
**kwargs
Additional keyword arguments passed to the solver.
Raises
------
RuntimeError
If solving status is infeasible or warning
ObjectiveValueError
If objective value differs from expected value
"""

Either way, the function does not return anything, so I don't think it's useful to document it in the docstring. Do you agree?

@lisazeyen lisazeyen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgilon thanks for preparing the PR! I agree with your suggestion for the rule grouping. There is just one minor comment about a docstring where I think the description for the return values is getting lost (but maybe this is intentional). Good to go from my side!

@lisazeyen
lisazeyen merged commit d426d73 into master Jul 20, 2026
7 checks passed
@lisazeyen
lisazeyen deleted the doc/document-tyndp-rules branch July 20, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CBA Cost Benefit Analysis SB Scenario Building

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants