Skip to content

Commit c8870c5

Browse files
[pre-commit.ci] pre-commit autoupdate (#1954)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.3 → v0.14.10](astral-sh/ruff-pre-commit@v0.13.3...v0.14.10) - [github.com/fsfe/reuse-tool: v6.0.0 → v6.2.0](fsfe/reuse-tool@v6.0.0...v6.2.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: types --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: lkstrp <lkstrp@pm.me>
1 parent 9920a9f commit c8870c5

10 files changed

+43
-52
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
# Run ruff to lint and format
1818
- repo: https://github.com/astral-sh/ruff-pre-commit
1919
# Ruff version.
20-
rev: v0.13.3
20+
rev: v0.14.10
2121
hooks:
2222
# Run the linter.
2323
- id: ruff
@@ -58,6 +58,6 @@ repos:
5858

5959
# Check for FSFE REUSE compliance (licensing)
6060
- repo: https://github.com/fsfe/reuse-tool
61-
rev: v6.0.0
61+
rev: v6.2.0
6262
hooks:
6363
- id: reuse-lint-file

scripts/_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import os
99
import re
1010
import time
11+
from collections.abc import Callable
1112
from functools import partial, wraps
1213
from pathlib import Path
1314
from tempfile import NamedTemporaryFile
14-
from typing import Callable, Union
1515

1616
import atlite
1717
import fiona
@@ -990,7 +990,7 @@ def rename_techs(label: str) -> str:
990990

991991

992992
def load_cutout(
993-
cutout_files: Union[str, list[str]], time: Union[None, pd.DatetimeIndex] = None
993+
cutout_files: str | list[str], time: None | pd.DatetimeIndex = None
994994
) -> atlite.Cutout:
995995
"""
996996
Load and optionally combine multiple cutout files.

scripts/build_co2_sequestration_potentials.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
database_en>`_.
88
"""
99

10-
from typing import Any, Union
10+
from typing import Any
1111

1212
import geopandas as gpd
1313
import numpy as np
@@ -19,8 +19,8 @@
1919

2020

2121
def convert_to_2d(
22-
geom: Union[sg.base.BaseGeometry, Any],
23-
) -> Union[sg.base.BaseGeometry, Any]:
22+
geom: sg.base.BaseGeometry | Any,
23+
) -> sg.base.BaseGeometry | Any:
2424
"""
2525
Remove the third dimension (z-coordinate) from a shapely geometry object.
2626

scripts/build_cop_profiles/base_cop_approximator.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# SPDX-License-Identifier: MIT
44

55
from abc import ABC, abstractmethod
6-
from typing import Union
76

87
import numpy as np
98
import xarray as xr
@@ -35,8 +34,8 @@ class BaseCopApproximator(ABC):
3534

3635
def __init__(
3736
self,
38-
sink_outlet_temperature_celsius: Union[xr.DataArray, np.array],
39-
source_inlet_temperature_celsius: Union[xr.DataArray, np.array],
37+
sink_outlet_temperature_celsius: xr.DataArray | np.ndarray,
38+
source_inlet_temperature_celsius: xr.DataArray | np.ndarray,
4039
):
4140
"""
4241
Initialize CopApproximator.
@@ -51,7 +50,7 @@ def __init__(
5150
pass
5251

5352
@property
54-
def cop(self) -> Union[xr.DataArray, np.array]:
53+
def cop(self) -> xr.DataArray | np.ndarray:
5554
"""
5655
Calculate the coefficient of performance (COP) for the system.
5756
@@ -70,7 +69,7 @@ def cop(self) -> Union[xr.DataArray, np.array]:
7069
return ret_val
7170

7271
@abstractmethod
73-
def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
72+
def _approximate_cop(self) -> xr.DataArray | np.ndarray:
7473
"""
7574
Approximate heat pump coefficient of performance (COP).
7675
@@ -83,8 +82,8 @@ def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
8382

8483
@staticmethod
8584
def celsius_to_kelvin(
86-
t_celsius: Union[float, xr.DataArray, np.array],
87-
) -> Union[float, xr.DataArray, np.array]:
85+
t_celsius: float | xr.DataArray | np.ndarray,
86+
) -> float | xr.DataArray | np.ndarray:
8887
"""
8988
Convert temperature from Celsius to Kelvin.
9089
@@ -106,9 +105,9 @@ def celsius_to_kelvin(
106105

107106
@staticmethod
108107
def logarithmic_mean(
109-
t_hot: Union[float, xr.DataArray, np.ndarray],
110-
t_cold: Union[float, xr.DataArray, np.ndarray],
111-
) -> Union[float, xr.DataArray, np.ndarray]:
108+
t_hot: float | xr.DataArray | np.ndarray,
109+
t_cold: float | xr.DataArray | np.ndarray,
110+
) -> float | xr.DataArray | np.ndarray:
112111
"""
113112
Calculate the logarithmic mean temperature difference.
114113

scripts/build_cop_profiles/central_heating_cop_approximator.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# SPDX-License-Identifier: MIT
44

55

6-
from typing import Union
7-
86
import numpy as np
97
import xarray as xr
108

@@ -110,10 +108,10 @@ class CentralHeatingCopApproximator(BaseCopApproximator):
110108

111109
def __init__(
112110
self,
113-
sink_outlet_temperature_celsius: Union[xr.DataArray, np.array],
114-
source_inlet_temperature_celsius: Union[xr.DataArray, np.array],
115-
sink_inlet_temperature_celsius: Union[xr.DataArray, np.array],
116-
source_outlet_temperature_celsius: Union[xr.DataArray, np.array],
111+
sink_outlet_temperature_celsius: xr.DataArray | np.ndarray,
112+
source_inlet_temperature_celsius: xr.DataArray | np.ndarray,
113+
sink_inlet_temperature_celsius: xr.DataArray | np.ndarray,
114+
source_outlet_temperature_celsius: xr.DataArray | np.ndarray,
117115
refrigerant: str,
118116
delta_t_pinch_point: float,
119117
isentropic_compressor_efficiency: float,
@@ -163,7 +161,7 @@ def __init__(
163161
self.delta_t_pinch = delta_t_pinch_point
164162
self.min_delta_t_lift = min_delta_t_lift
165163

166-
def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
164+
def _approximate_cop(self) -> xr.DataArray | np.ndarray:
167165
"""
168166
Calculate the coefficient of performance (COP) for the system.
169167
@@ -203,7 +201,7 @@ def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
203201
)
204202

205203
@property
206-
def t_sink_mean_kelvin(self) -> Union[xr.DataArray, np.array]:
204+
def t_sink_mean_kelvin(self) -> xr.DataArray | np.ndarray:
207205
"""
208206
Calculate the logarithmic mean temperature difference between the cold
209207
and hot sinks.
@@ -218,7 +216,7 @@ def t_sink_mean_kelvin(self) -> Union[xr.DataArray, np.array]:
218216
)
219217

220218
@property
221-
def t_source_mean_kelvin(self) -> Union[xr.DataArray, np.array]:
219+
def t_source_mean_kelvin(self) -> xr.DataArray | np.ndarray:
222220
"""
223221
Calculate the logarithmic mean temperature of the heat source.
224222
@@ -232,7 +230,7 @@ def t_source_mean_kelvin(self) -> Union[xr.DataArray, np.array]:
232230
)
233231

234232
@property
235-
def delta_t_mean_lift(self) -> Union[xr.DataArray, np.array]:
233+
def delta_t_mean_lift(self) -> xr.DataArray | np.ndarray:
236234
"""
237235
Calculate the temperature lift as the difference between the
238236
logarithmic sink and source temperatures.
@@ -245,15 +243,15 @@ def delta_t_mean_lift(self) -> Union[xr.DataArray, np.array]:
245243
return self.t_sink_mean_kelvin - self.t_source_mean_kelvin
246244

247245
@property
248-
def delta_t_lift(self) -> Union[xr.DataArray, np.array]:
246+
def delta_t_lift(self) -> xr.DataArray | np.ndarray:
249247
"""
250248
Calculate the temperature lift as the difference between the
251249
sink and source temperatures.
252250
"""
253251
return self.t_sink_out_kelvin - self.t_source_in_kelvin
254252

255253
@property
256-
def ideal_lorenz_cop(self) -> Union[xr.DataArray, np.array]:
254+
def ideal_lorenz_cop(self) -> xr.DataArray | np.ndarray:
257255
"""
258256
Ideal Lorenz coefficient of performance (COP).
259257
@@ -268,7 +266,7 @@ def ideal_lorenz_cop(self) -> Union[xr.DataArray, np.array]:
268266
return self.t_sink_mean_kelvin / self.delta_t_mean_lift
269267

270268
@property
271-
def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]:
269+
def delta_t_refrigerant_source(self) -> xr.DataArray | np.ndarray:
272270
"""
273271
Calculate the temperature difference between the refrigerant source
274272
inlet and outlet.
@@ -283,7 +281,7 @@ def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]:
283281
)
284282

285283
@property
286-
def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]:
284+
def delta_t_refrigerant_sink(self) -> xr.DataArray | np.ndarray:
287285
"""
288286
Temperature difference between the refrigerant and the sink based on
289287
approximation.
@@ -296,7 +294,7 @@ def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]:
296294
return self._approximate_delta_t_refrigerant_sink(self.refrigerant)
297295

298296
@property
299-
def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]:
297+
def ratio_evaporation_compression_work(self) -> xr.DataArray | np.ndarray:
300298
"""
301299
Calculate the ratio of evaporation to compression work based on
302300
approximation.
@@ -309,7 +307,7 @@ def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]:
309307
return self._ratio_evaporation_compression_work_approximation(self.refrigerant)
310308

311309
@property
312-
def delta_t_sink(self) -> Union[xr.DataArray, np.array]:
310+
def delta_t_sink(self) -> xr.DataArray | np.ndarray:
313311
"""
314312
Calculate the temperature difference at the sink.
315313
@@ -321,8 +319,8 @@ def delta_t_sink(self) -> Union[xr.DataArray, np.array]:
321319
return self.t_sink_out_kelvin - self.t_sink_in_kelvin
322320

323321
def _approximate_delta_t_refrigerant_source(
324-
self, delta_t_source: Union[xr.DataArray, np.array]
325-
) -> Union[xr.DataArray, np.array]:
322+
self, delta_t_source: xr.DataArray | np.ndarray
323+
) -> xr.DataArray | np.ndarray:
326324
"""
327325
Approximates the temperature difference between the refrigerant and the
328326
source.
@@ -345,7 +343,7 @@ def _approximate_delta_t_refrigerant_sink(
345343
a: float = {"ammonia": 0.2, "isobutane": -0.0011},
346344
b: float = {"ammonia": 0.2, "isobutane": 0.3},
347345
c: float = {"ammonia": 0.016, "isobutane": 2.4},
348-
) -> Union[xr.DataArray, np.array]:
346+
) -> xr.DataArray | np.ndarray:
349347
"""
350348
Approximates the temperature difference between the refrigerant and
351349
heat sink.
@@ -394,7 +392,7 @@ def _ratio_evaporation_compression_work_approximation(
394392
a: float = {"ammonia": 0.0014, "isobutane": 0.0035},
395393
b: float = {"ammonia": -0.0015, "isobutane": -0.0033},
396394
c: float = {"ammonia": 0.039, "isobutane": 0.053},
397-
) -> Union[xr.DataArray, np.array]:
395+
) -> xr.DataArray | np.ndarray:
398396
"""
399397
Calculate the ratio of evaporation to compression work approximation.
400398

scripts/build_cop_profiles/decentral_heating_cop_approximator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# SPDX-License-Identifier: MIT
44

55

6-
from typing import Union
7-
86
import numpy as np
97
import xarray as xr
108

@@ -45,8 +43,8 @@ class DecentralHeatingCopApproximator(BaseCopApproximator):
4543

4644
def __init__(
4745
self,
48-
sink_outlet_temperature_celsius: Union[xr.DataArray, np.array],
49-
source_inlet_temperature_celsius: Union[xr.DataArray, np.array],
46+
sink_outlet_temperature_celsius: xr.DataArray | np.ndarray,
47+
source_inlet_temperature_celsius: xr.DataArray | np.ndarray,
5048
source_type: str,
5149
):
5250
"""
@@ -70,7 +68,7 @@ def __init__(
7068
else:
7169
self.source_type = source_type
7270

73-
def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
71+
def _approximate_cop(self) -> xr.DataArray | np.ndarray:
7472
"""
7573
Compute the COP values using quadratic regression for air-/ground-
7674
source heat pumps.
@@ -85,7 +83,7 @@ def _approximate_cop(self) -> Union[xr.DataArray, np.array]:
8583
elif self.source_type == "ground":
8684
return self._approximate_cop_ground_source()
8785

88-
def _approximate_cop_air_source(self) -> Union[xr.DataArray, np.array]:
86+
def _approximate_cop_air_source(self) -> xr.DataArray | np.ndarray:
8987
"""
9088
Evaluate quadratic regression for an air-sourced heat pump.
9189
@@ -98,7 +96,7 @@ def _approximate_cop_air_source(self) -> Union[xr.DataArray, np.array]:
9896
"""
9997
return 6.81 - 0.121 * self.delta_t + 0.000630 * self.delta_t**2
10098

101-
def _approximate_cop_ground_source(self) -> Union[xr.DataArray, np.array]:
99+
def _approximate_cop_ground_source(self) -> xr.DataArray | np.ndarray:
102100
"""
103101
Evaluate quadratic regression for a ground-sourced heat pump.
104102

scripts/build_surface_water_heat_potentials/approximators/river_water_heat_approximator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: MIT
44
import warnings
5-
from typing import Union
65

76
import geopandas as gpd
87
import numpy as np
@@ -29,7 +28,7 @@ def __init__(
2928
self,
3029
volume_flow: xr.DataArray,
3130
ambient_temperature: xr.DataArray,
32-
region: Union[shapely.geometry.polygon.Polygon, gpd.GeoSeries],
31+
region: shapely.geometry.polygon.Polygon | gpd.GeoSeries,
3332
max_relative_volume_flow: float = 1.0,
3433
delta_t_max: float = 1,
3534
min_outlet_temperature: float = 1,

scripts/build_surface_water_heat_potentials/approximators/sea_water_heat_approximator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: MIT
44
import logging
5-
from typing import Union
65

76
import geopandas as gpd
87
import shapely
@@ -30,7 +29,7 @@ class SeaWaterHeatApproximator(SurfaceWaterHeatApproximator):
3029
def __init__(
3130
self,
3231
water_temperature: xr.DataArray,
33-
region: Union[shapely.geometry.polygon.Polygon, gpd.GeoSeries],
32+
region: shapely.geometry.polygon.Polygon | gpd.GeoSeries,
3433
min_inlet_temperature: float = 1,
3534
) -> None:
3635
# buffer the region geometry by half the data resolution

scripts/build_surface_water_heat_potentials/approximators/surface_water_heat_approximator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
from abc import ABC
66
from functools import cached_property
7-
from typing import Union
87

98
import geopandas as gpd
109
import numpy as np
@@ -33,7 +32,7 @@ def __init__(
3332
self,
3433
volume_flow: xr.DataArray,
3534
water_temperature: xr.DataArray,
36-
region: Union[shapely.geometry.polygon.Polygon, gpd.GeoSeries],
35+
region: shapely.geometry.polygon.Polygon | gpd.GeoSeries,
3736
max_relative_volume_flow: float = 1.0,
3837
delta_t_max: float = 4,
3938
min_outlet_temperature: float = 1,

scripts/plot_heat_source_map.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"""
4747

4848
import logging
49-
from typing import Optional
5049

5150
import folium
5251
import geopandas as gpd
@@ -67,7 +66,7 @@ def plot_heat_source_map(
6766
longitude_name: str = "longitude",
6867
latitude_name: str = "latitude",
6968
onshore_region_name: str = "name",
70-
title: Optional[str] = None,
69+
title: str | None = None,
7170
cmap: str = "viridis",
7271
aggregate_type: str = "mean", # 'mean' for temperature, 'sum' for energy
7372
) -> folium.Map:

0 commit comments

Comments
 (0)