From aed663ecefbfc70c0281dd990579eaec5f4ffff5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 18:38:21 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.3 → v0.14.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.13.3...v0.14.10) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75b662491..a69d7a203 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: # Run ruff to lint and format - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.13.3 + rev: v0.14.10 hooks: # Run the linter. - id: ruff From e32148ef851b111b7c5982af410bae92c34240ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 18:39:09 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/_helpers.py | 4 +- scripts/build_co2_sequestration_potentials.py | 6 +-- .../build_cop_profiles/BaseCopApproximator.py | 17 ++++----- .../CentralHeatingCopApproximator.py | 38 +++++++++---------- .../DecentralHeatingCopApproximator.py | 12 +++--- 5 files changed, 36 insertions(+), 41 deletions(-) diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 4fae083a2..c64087cfa 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -9,10 +9,10 @@ import os import re import time +from collections.abc import Callable from functools import partial, wraps from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Callable, Union import atlite import fiona @@ -1058,7 +1058,7 @@ def rename_techs(label: str) -> str: def load_cutout( - cutout_files: Union[str, list[str]], time: Union[None, pd.DatetimeIndex] = None + cutout_files: str | list[str], time: None | pd.DatetimeIndex = None ) -> atlite.Cutout: """ Load and optionally combine multiple cutout files. diff --git a/scripts/build_co2_sequestration_potentials.py b/scripts/build_co2_sequestration_potentials.py index a8334dc29..238839b3e 100644 --- a/scripts/build_co2_sequestration_potentials.py +++ b/scripts/build_co2_sequestration_potentials.py @@ -7,7 +7,7 @@ database_en>`_. """ -from typing import Any, Union +from typing import Any import geopandas as gpd import numpy as np @@ -19,8 +19,8 @@ def convert_to_2d( - geom: Union[sg.base.BaseGeometry, Any], -) -> Union[sg.base.BaseGeometry, Any]: + geom: sg.base.BaseGeometry | Any, +) -> sg.base.BaseGeometry | Any: """ Remove the third dimension (z-coordinate) from a shapely geometry object. diff --git a/scripts/build_cop_profiles/BaseCopApproximator.py b/scripts/build_cop_profiles/BaseCopApproximator.py index c3b93d26f..1f005d958 100644 --- a/scripts/build_cop_profiles/BaseCopApproximator.py +++ b/scripts/build_cop_profiles/BaseCopApproximator.py @@ -3,7 +3,6 @@ # SPDX-License-Identifier: MIT from abc import ABC, abstractmethod -from typing import Union import numpy as np import xarray as xr @@ -35,8 +34,8 @@ class BaseCopApproximator(ABC): def __init__( self, - sink_outlet_temperature_celsius: Union[xr.DataArray, np.array], - source_inlet_temperature_celsius: Union[xr.DataArray, np.array], + sink_outlet_temperature_celsius: xr.DataArray | np.array, + source_inlet_temperature_celsius: xr.DataArray | np.array, ): """ Initialize CopApproximator. @@ -51,7 +50,7 @@ def __init__( pass @abstractmethod - def approximate_cop(self) -> Union[xr.DataArray, np.array]: + def approximate_cop(self) -> xr.DataArray | np.array: """ Approximate heat pump coefficient of performance (COP). @@ -64,8 +63,8 @@ def approximate_cop(self) -> Union[xr.DataArray, np.array]: @staticmethod def celsius_to_kelvin( - t_celsius: Union[float, xr.DataArray, np.array], - ) -> Union[float, xr.DataArray, np.array]: + t_celsius: float | xr.DataArray | np.array, + ) -> float | xr.DataArray | np.array: """ Convert temperature from Celsius to Kelvin. @@ -87,9 +86,9 @@ def celsius_to_kelvin( @staticmethod def logarithmic_mean( - t_hot: Union[float, xr.DataArray, np.ndarray], - t_cold: Union[float, xr.DataArray, np.ndarray], - ) -> Union[float, xr.DataArray, np.ndarray]: + t_hot: float | xr.DataArray | np.ndarray, + t_cold: float | xr.DataArray | np.ndarray, + ) -> float | xr.DataArray | np.ndarray: """ Calculate the logarithmic mean temperature difference. diff --git a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py index d19ab0147..d06267a0d 100644 --- a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py @@ -3,8 +3,6 @@ # SPDX-License-Identifier: MIT -from typing import Union - import numpy as np import xarray as xr @@ -110,10 +108,10 @@ class CentralHeatingCopApproximator(BaseCopApproximator): def __init__( self, - sink_outlet_temperature_celsius: Union[xr.DataArray, np.array], - source_inlet_temperature_celsius: Union[xr.DataArray, np.array], - sink_inlet_temperature_celsius: Union[xr.DataArray, np.array], - source_outlet_temperature_celsius: Union[xr.DataArray, np.array], + sink_outlet_temperature_celsius: xr.DataArray | np.array, + source_inlet_temperature_celsius: xr.DataArray | np.array, + sink_inlet_temperature_celsius: xr.DataArray | np.array, + source_outlet_temperature_celsius: xr.DataArray | np.array, refrigerant: str, delta_t_pinch_point: float, isentropic_compressor_efficiency: float, @@ -163,7 +161,7 @@ def __init__( self.delta_t_pinch = delta_t_pinch_point self.min_delta_t_lift = min_delta_t_lift - def approximate_cop(self) -> Union[xr.DataArray, np.array]: + def approximate_cop(self) -> xr.DataArray | np.array: """ Calculate the coefficient of performance (COP) for the system. @@ -203,7 +201,7 @@ def approximate_cop(self) -> Union[xr.DataArray, np.array]: ) @property - def t_sink_mean_kelvin(self) -> Union[xr.DataArray, np.array]: + def t_sink_mean_kelvin(self) -> xr.DataArray | np.array: """ Calculate the logarithmic mean temperature difference between the cold and hot sinks. @@ -218,7 +216,7 @@ def t_sink_mean_kelvin(self) -> Union[xr.DataArray, np.array]: ) @property - def t_source_mean_kelvin(self) -> Union[xr.DataArray, np.array]: + def t_source_mean_kelvin(self) -> xr.DataArray | np.array: """ Calculate the logarithmic mean temperature of the heat source. @@ -232,7 +230,7 @@ def t_source_mean_kelvin(self) -> Union[xr.DataArray, np.array]: ) @property - def delta_t_mean_lift(self) -> Union[xr.DataArray, np.array]: + def delta_t_mean_lift(self) -> xr.DataArray | np.array: """ Calculate the temperature lift as the difference between the logarithmic sink and source temperatures. @@ -245,7 +243,7 @@ def delta_t_mean_lift(self) -> Union[xr.DataArray, np.array]: return self.t_sink_mean_kelvin - self.t_source_mean_kelvin @property - def delta_t_lift(self) -> Union[xr.DataArray, np.array]: + def delta_t_lift(self) -> xr.DataArray | np.array: """ Calculate the temperature lift as the difference between the sink and source temperatures. @@ -253,7 +251,7 @@ def delta_t_lift(self) -> Union[xr.DataArray, np.array]: return self.t_sink_out_kelvin - self.t_source_in_kelvin @property - def ideal_lorenz_cop(self) -> Union[xr.DataArray, np.array]: + def ideal_lorenz_cop(self) -> xr.DataArray | np.array: """ Ideal Lorenz coefficient of performance (COP). @@ -268,7 +266,7 @@ def ideal_lorenz_cop(self) -> Union[xr.DataArray, np.array]: return self.t_sink_mean_kelvin / self.delta_t_mean_lift @property - def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]: + def delta_t_refrigerant_source(self) -> xr.DataArray | np.array: """ Calculate the temperature difference between the refrigerant source inlet and outlet. @@ -283,7 +281,7 @@ def delta_t_refrigerant_source(self) -> Union[xr.DataArray, np.array]: ) @property - def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]: + def delta_t_refrigerant_sink(self) -> xr.DataArray | np.array: """ Temperature difference between the refrigerant and the sink based on approximation. @@ -296,7 +294,7 @@ def delta_t_refrigerant_sink(self) -> Union[xr.DataArray, np.array]: return self._approximate_delta_t_refrigerant_sink(self.refrigerant) @property - def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]: + def ratio_evaporation_compression_work(self) -> xr.DataArray | np.array: """ Calculate the ratio of evaporation to compression work based on approximation. @@ -309,7 +307,7 @@ def ratio_evaporation_compression_work(self) -> Union[xr.DataArray, np.array]: return self._ratio_evaporation_compression_work_approximation(self.refrigerant) @property - def delta_t_sink(self) -> Union[xr.DataArray, np.array]: + def delta_t_sink(self) -> xr.DataArray | np.array: """ Calculate the temperature difference at the sink. @@ -321,8 +319,8 @@ def delta_t_sink(self) -> Union[xr.DataArray, np.array]: return self.t_sink_out_kelvin - self.t_sink_in_kelvin def _approximate_delta_t_refrigerant_source( - self, delta_t_source: Union[xr.DataArray, np.array] - ) -> Union[xr.DataArray, np.array]: + self, delta_t_source: xr.DataArray | np.array + ) -> xr.DataArray | np.array: """ Approximates the temperature difference between the refrigerant and the source. @@ -345,7 +343,7 @@ def _approximate_delta_t_refrigerant_sink( a: float = {"ammonia": 0.2, "isobutane": -0.0011}, b: float = {"ammonia": 0.2, "isobutane": 0.3}, c: float = {"ammonia": 0.016, "isobutane": 2.4}, - ) -> Union[xr.DataArray, np.array]: + ) -> xr.DataArray | np.array: """ Approximates the temperature difference between the refrigerant and heat sink. @@ -394,7 +392,7 @@ def _ratio_evaporation_compression_work_approximation( a: float = {"ammonia": 0.0014, "isobutane": 0.0035}, b: float = {"ammonia": -0.0015, "isobutane": -0.0033}, c: float = {"ammonia": 0.039, "isobutane": 0.053}, - ) -> Union[xr.DataArray, np.array]: + ) -> xr.DataArray | np.array: """ Calculate the ratio of evaporation to compression work approximation. diff --git a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py index 741b2ea28..a5ba16799 100644 --- a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py @@ -3,8 +3,6 @@ # SPDX-License-Identifier: MIT -from typing import Union - import numpy as np import xarray as xr @@ -45,8 +43,8 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): def __init__( self, - sink_outlet_temperature_celsius: Union[xr.DataArray, np.array], - source_inlet_temperature_celsius: Union[xr.DataArray, np.array], + sink_outlet_temperature_celsius: xr.DataArray | np.array, + source_inlet_temperature_celsius: xr.DataArray | np.array, source_type: str, ): """ @@ -70,7 +68,7 @@ def __init__( else: self.source_type = source_type - def approximate_cop(self) -> Union[xr.DataArray, np.array]: + def approximate_cop(self) -> xr.DataArray | np.array: """ Compute the COP values using quadratic regression for air-/ground- source heat pumps. @@ -85,7 +83,7 @@ def approximate_cop(self) -> Union[xr.DataArray, np.array]: elif self.source_type == "ground": return self._approximate_cop_ground_source() - def _approximate_cop_air_source(self) -> Union[xr.DataArray, np.array]: + def _approximate_cop_air_source(self) -> xr.DataArray | np.array: """ Evaluate quadratic regression for an air-sourced heat pump. @@ -98,7 +96,7 @@ def _approximate_cop_air_source(self) -> Union[xr.DataArray, np.array]: """ return 6.81 - 0.121 * self.delta_t + 0.000630 * self.delta_t**2 - def _approximate_cop_ground_source(self) -> Union[xr.DataArray, np.array]: + def _approximate_cop_ground_source(self) -> xr.DataArray | np.array: """ Evaluate quadratic regression for a ground-sourced heat pump.