diff --git a/doc/release_notes.md b/doc/release_notes.md index 79c6bf77cc..00f2e3b6ac 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -43,6 +43,8 @@ * Introduce SBOM/Grype vulnerability scanning workflow, as a follow-up to the [upstream addition](https://github.com/PyPSA/pypsa-eur/pull/2164) ([754](https://github.com/open-energy-transition/open-tyndp/pull/754)). +* Ensure `inflow_t` is always defined in `attach_hydro`, resolving a pylint use-before-assignment issue ([777](https://github.com/open-energy-transition/open-tyndp/pull/777)). + ## Upcoming PyPSA-Eur Release * Security: SBOM security scan included in CI. diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 3d324a6d76..efe64b62e0 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -878,6 +878,7 @@ def attach_hydro( country = ppl["bus"].map(n.buses.country).rename("country") inflow_idx = ror.index.union(hydro.index) + inflow_t = pd.DataFrame() if not inflow_idx.empty: dist_key = ppl.loc[inflow_idx, "p_nom"].groupby(country).transform(normed) @@ -911,7 +912,7 @@ def attach_hydro( capital_cost=costs.at["ror", "capital_cost"], weight=ror["p_nom"], p_max_pu=( - inflow_t[ror.index] # pylint: disable=E0606 + inflow_t[ror.index] .divide(ror["p_nom"], axis=1) .where(lambda df: df <= 1.0, other=1.0) ),