diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3ade226..37fc3bc2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.11 + rev: v0.15.0 hooks: - id: ruff-format types_or: [python, pyi, jupyter] @@ -21,7 +21,7 @@ repos: hooks: - id: markdownlint-fix - repo: https://github.com/kynan/nbstripout - rev: 0.8.2 + rev: 0.9.0 hooks: - id: nbstripout files: ".ipynb" diff --git a/docs/user-guide/add-region.ipynb b/docs/user-guide/add-region.ipynb index 8ab1a791..fcc9c22b 100644 --- a/docs/user-guide/add-region.ipynb +++ b/docs/user-guide/add-region.ipynb @@ -112,11 +112,11 @@ " )\n", " g = sns.FacetGrid(data=sector_capacity, col=\"region\")\n", " g.map_dataframe(\n", - " lambda data, **kwargs: data.pivot(\n", - " index=\"year\", columns=\"technology\", values=\"capacity\"\n", + " lambda data, **kwargs: (\n", + " data.pivot(index=\"year\", columns=\"technology\", values=\"capacity\")\n", + " .reindex(all_years)\n", + " .plot(kind=\"bar\", stacked=True, ax=plt.gca())\n", " )\n", - " .reindex(all_years)\n", - " .plot(kind=\"bar\", stacked=True, ax=plt.gca())\n", " )\n", " g.add_legend()\n", " g.set_ylabels(\"Capacity (PJ)\")\n", diff --git a/src/muse/outputs/cache.py b/src/muse/outputs/cache.py index 0c00eb09..eb0b8efe 100644 --- a/src/muse/outputs/cache.py +++ b/src/muse/outputs/cache.py @@ -384,10 +384,12 @@ def check_col(colname: str) -> str: return colname return reduce( - lambda left, right: pd.DataFrame.merge(left, right, how="outer", on=cols) - .T.groupby(check_col) - .last() - .T, + lambda left, right: ( + pd.DataFrame.merge(left, right, how="outer", on=cols) + .T.groupby(check_col) + .last() + .T + ), data, ) diff --git a/tests/test_minimum_service.py b/tests/test_minimum_service.py index c75d7479..50545ff1 100644 --- a/tests/test_minimum_service.py +++ b/tests/test_minimum_service.py @@ -71,10 +71,14 @@ def test_minimum_service_factor(check_mock, tmp_path, minimum_service_factors): for process, service_factor in zip(processes, minimum_service_factors): supply_process = supply[supply.technology == process] supply_process.loc[:, "min_supply"] = supply_process.apply( - lambda x: x.capacity - * service_factor[x.timeslice] - * float( - techno_out[techno_out.ProcessName == process]["electricity"].values[0] + lambda x: ( + x.capacity + * service_factor[x.timeslice] + * float( + techno_out[techno_out.ProcessName == process]["electricity"].values[ + 0 + ] + ) ), axis=1, )