diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d43f0859..f6569467 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: exclude: ^uv.lock$|tests/trace_data/ - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.15.0 + rev: v0.16.5 hooks: # Run the linter. - id: ruff diff --git a/CLAUDE.md b/CLAUDE.md index 533dba2f..306c5c83 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -16,7 +16,9 @@ helper functions. ```python def template_network_transmission_paths(iasr_tables, scenario): paths = _extract_flow_paths(iasr_tables["flow_path_transfer_capability"]) - paths = _add_transfer_limits(paths, iasr_tables["interconnector_transfer_capability"]) + paths = _add_transfer_limits( + paths, iasr_tables["interconnector_transfer_capability"] + ) paths = _filter_to_scenario(paths, scenario) return paths ``` diff --git a/docs/api.md b/docs/api.md index 584572b7..f1483742 100644 --- a/docs/api.md +++ b/docs/api.md @@ -18,7 +18,7 @@ edit the code to point at an ispypsa_config.yaml file of your choice, then run t Python script. ```Python ---8<-- "example_workflow.py" +--8 < --"example_workflow.py" ``` ## Configuration & Logging diff --git a/docs/examples/example_api_workflow.md b/docs/examples/example_api_workflow.md index b97a70a4..46689c52 100644 --- a/docs/examples/example_api_workflow.md +++ b/docs/examples/example_api_workflow.md @@ -4,5 +4,5 @@ edit the code to point at an ispypsa_config.yaml file of your choice, then run t Python script. ```Python ---8<-- "example_workflow.py" +--8 < --"example_workflow.py" ``` diff --git a/docs/workflow.md b/docs/workflow.md index ea531112..92053214 100644 --- a/docs/workflow.md +++ b/docs/workflow.md @@ -26,10 +26,7 @@ either the ISPyPSA CLI or API: ```Python from ispypsa.data_fetch import fetch_workbook - fetch_workbook( - workbook_version="6.0", - save_path="path/to/save/iasr_workbook.xlsx" - ) + fetch_workbook(workbook_version="6.0", save_path="path/to/save/iasr_workbook.xlsx") ``` ### Trace data @@ -53,9 +50,7 @@ or API: from ispypsa.data_fetch import fetch_trace_data fetch_trace_data( - dataset_type="example", - dataset_year=2024, - save_directory="path/to/save/directory" + dataset_type="example", dataset_year=2024, save_directory="path/to/save/directory" ) ``` @@ -84,7 +79,7 @@ parsing can be run using either the ISPyPSA CLI or API: build_local_cache( cache_path="path/to/cache/location", workbook_path="path/to/iasr_workbook.xlsx", - iasr_workbook_version="6.0" + iasr_workbook_version="6.0", ) ``` @@ -140,9 +135,7 @@ run using either ISPyPSA CLI or API. # Get raw IASR tables iasr_tables = read_csvs(parsed_workbook_cache) - manually_extracted_tables = load_manually_extracted_tables( - config.iasr_workbook_version - ) + manually_extracted_tables = load_manually_extracted_tables(config.iasr_workbook_version) # Create ISPyPSA inputs from IASR tables. ispypsa_tables = create_ispypsa_inputs_template( @@ -276,7 +269,9 @@ you can also create the PyPSA friendly operational timeseries data at this stage operational_timeseries_location, ) - write_csvs({"operational_snapshots": operational_snapshots}, pypsa_friendly_inputs_location) + write_csvs( + {"operational_snapshots": operational_snapshots}, pypsa_friendly_inputs_location + ) ``` ## PyPSA building and run @@ -312,12 +307,8 @@ constraints are not preserved when the PyPSA network object is saved to disk. pypsa_friendly_inputs_location = ( run_directory / config.paths.ispypsa_run_name / "pypsa_friendly" ) - timeseries_location = ( - pypsa_friendly_inputs_location / "capacity_expansion_timeseries" - ) - pypsa_outputs_directory = ( - run_directory / config.paths.ispypsa_run_name / "outputs" - ) + timeseries_location = pypsa_friendly_inputs_location / "capacity_expansion_timeseries" + pypsa_outputs_directory = run_directory / config.paths.ispypsa_run_name / "outputs" # Load pypsa friendly inputs pypsa_tables = read_csvs(pypsa_friendly_inputs_location) @@ -333,11 +324,7 @@ constraints are not preserved when the PyPSA network object is saved to disk. network.optimize.solve_model(solver_name=config.solver) # Save results. - save_pypsa_network( - network, - pypsa_outputs_directory, - "capacity_expansion" - ) + save_pypsa_network(network, pypsa_outputs_directory, "capacity_expansion") ``` ### Operational model @@ -381,12 +368,8 @@ computational complexity. operational_timeseries_location = ( pypsa_friendly_inputs_location / "operational_timeseries" ) - pypsa_outputs_directory = ( - run_directory / config.paths.ispypsa_run_name / "outputs" - ) - capacity_expansion_pypsa_file = ( - pypsa_outputs_directory / "capacity_expansion.nc" - ) + pypsa_outputs_directory = run_directory / config.paths.ispypsa_run_name / "outputs" + capacity_expansion_pypsa_file = pypsa_outputs_directory / "capacity_expansion.nc" # Load pypsa friendly inputs pypsa_tables = read_csvs(pypsa_friendly_inputs_location) @@ -410,9 +393,5 @@ computational complexity. overlap=config.temporal.operational.overlap, ) - save_pypsa_network( - network, - pypsa_outputs_directory, - "operational" - ) + save_pypsa_network(network, pypsa_outputs_directory, "operational") ```