From bb9595944fcf673152ea53e61efbafeb0b1e4406 Mon Sep 17 00:00:00 2001 From: climada Date: Tue, 30 Sep 2025 09:52:05 +0000 Subject: [PATCH 1/7] 'Automated update v6.1.0' --- CHANGELOG.md | 8 ++------ climada/_version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7083cc1269..b7aa82b4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,8 @@ # Changelog -## Unreleased +## 6.1.0 -Release date: YYYY-MM-DD - -Code freeze date: YYYY-MM-DD - -### Description +Release date: 2025-09-30 ### Dependency Changes diff --git a/climada/_version.py b/climada/_version.py index b0826edc01..7856d1222b 100644 --- a/climada/_version.py +++ b/climada/_version.py @@ -1 +1 @@ -__version__ = "6.0.2-dev" +__version__ = "6.1.0" diff --git a/pyproject.toml b/pyproject.toml index 49ce786bdf..fce228793d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "climada" -version = "6.0.2-dev" +version = "6.1.0" description = "Framework for climate risk assessment and adaptation option appraisal" readme = "README.md" requires-python = ">=3.10,<3.13" From 42e5160a20afdf8f92d589b708977c5cf8ae9b5f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:14:21 +0100 Subject: [PATCH 2/7] ci: Add job for Mamba installation (#1251) * ci: Add job for Mamba installation * ci: Import CLIMADA in bash and powershell * ci: Run impact test when testing the installation --- .github/workflows/test-install.yml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/test-install.yml diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml new file mode 100644 index 0000000000..65994b79b7 --- /dev/null +++ b/.github/workflows/test-install.yml @@ -0,0 +1,49 @@ +# Check if installation with conda/mamba works + +name: Install Test + +on: + schedule: + - cron: "0 6 * * *" + workflow_dispatch: + +jobs: + install-conda: + name: Install from Conda + timeout-minutes: 10 + + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12"] + os: [ubuntu-latest, windows-latest, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - + name: Install with Mamba + uses: mamba-org/setup-micromamba@v2 + with: + environment-name: climada_env_${{ matrix.python-version }} + create-args: >- + python=${{ matrix.python-version }} + climada + init-shell: bash powershell + # Recompute environment for each run, but possibly use cached downloads + cache-environment: false + cache-downloads: true + cache-downloads-key: downloads-${{ matrix.os }}-py${{ matrix.python-version }} + - + name: Test CLIMADA (bash) + shell: bash -el {0} + run: | + python -c "import climada" + python -m unittest climada.engine.test.test_impact + - + name: Test CLIMADA (powershell) + shell: pwsh + if: ${{ matrix.os == 'windows-latest' }} + run: | + python -c "import climada" + python -m unittest climada.engine.test.test_impact From b452bb039d54649766d7553dda365160727ca5fd Mon Sep 17 00:00:00 2001 From: Chris Fairless Date: Mon, 4 May 2026 19:07:49 +0200 Subject: [PATCH 3/7] Add more intuitive unit specification when creating Hazard object via attrs keyword The Hazard.from_raster method allows you to specify an `attrs` dictionary to set additional parameters in the created Hazard's `__init__` method. This commit - allows you to set both 'unit' and 'units' which will be used as the 'units' parameter when the Hazard object is created, with 'units' taking priority. Currently only 'unit' is accepted which is very counterintuitive, since all other attributes are exactly as specified in the `__init__` - adds an ATTRS_TO_CHECK constant to the hazard module's io.py so that the user can see what is supported in the source code (and removes a comment that suggests doing this). - updates the documentation --- climada/hazard/io.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/climada/hazard/io.py b/climada/hazard/io.py index 6f8bd01b09..3dea267fb9 100644 --- a/climada/hazard/io.py +++ b/climada/hazard/io.py @@ -44,6 +44,18 @@ LOGGER = logging.getLogger(__name__) +ATTRS_TO_CHECK = { + "event_name": (list, str), + "event_id": (np.ndarray, None), + "frequency": (np.ndarray, float), + "frequency_unit": (str, None), + "date": (np.ndarray, int), + "orig": (np.ndarray, bool), + "unit": (str, None), # For backward compatibility. Replaced by units. + "units": (str, None), +} +"""Additional attributes that can be specified when reading a raster file""" + DEF_VAR_EXCEL = { "sheet_name": {"inten": "hazard_intensity", "freq": "hazard_frequency"}, "col_name": { @@ -135,7 +147,8 @@ def from_raster( files_fraction : list(str) file names containing fraction attrs : dict, optional - name of Hazard attributes and their values + name of Hazard attributes and their values. See the ATTRS_TO_CHECK constant for supported attributes. + Missing attributes will be filled with sensible defaults. band : list(int), optional bands to read (starting at 1), default [1] haz_type : str, optional @@ -712,10 +725,7 @@ def _check_and_cast_elements( return attr_value - ## This should probably be defined as a CONSTANT? - attrs_to_check = {"event_name": (list, str), "event_id": (np.ndarray, None)} - - for attr_name, (expected_container, expected_dtype) in attrs_to_check.items(): + for attr_name, (expected_container, expected_dtype) in ATTRS_TO_CHECK.items(): attr_value = attrs.get(attr_name) if attr_value is not None: @@ -777,6 +787,8 @@ def _attrs_to_kwargs(attrs: Dict[str, Any], num_events: int) -> Dict[str, Any]: kwargs["orig"] = np.ones(kwargs["event_id"].size, bool) if "unit" in attrs: kwargs["units"] = attrs["unit"] + if "units" in attrs: + kwargs["units"] = attrs["units"] return kwargs From eb8e05d0bcae348b22ba793b94b62846ae1ac7b2 Mon Sep 17 00:00:00 2001 From: Chris Fairless Date: Mon, 4 May 2026 22:01:22 +0200 Subject: [PATCH 4/7] fixup --- climada/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/climada/_version.py b/climada/_version.py index 8bf977bc22..e3dc32b910 100644 --- a/climada/_version.py +++ b/climada/_version.py @@ -1 +1 @@ -__version__ = "6.1.1-dev" \ No newline at end of file +__version__ = "6.1.1-dev" From f9bc757d97f2c4e43905de6f47da0ba751ad0028 Mon Sep 17 00:00:00 2001 From: Chris Fairless Date: Mon, 4 May 2026 23:05:25 +0200 Subject: [PATCH 5/7] Make required attrs for creating Hazards via attrs more flexible - Allow event names that are integers (some test files have integer names) - even though this is NOT ALLOWED - Allow core or numpy integers/booleans/strings --- climada/hazard/io.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/climada/hazard/io.py b/climada/hazard/io.py index 3dea267fb9..0842c5ce42 100644 --- a/climada/hazard/io.py +++ b/climada/hazard/io.py @@ -33,7 +33,7 @@ import rasterio import xarray as xr from deprecation import deprecated -from scipy import sparse +from scipy import sparsehit_country_per_hazard import climada.util.constants as u_const import climada.util.coordinates as u_coord @@ -45,12 +45,12 @@ LOGGER = logging.getLogger(__name__) ATTRS_TO_CHECK = { - "event_name": (list, str), + "event_name": (list, (str, np.str_, int, np.integer)), # int for backward compatibility "event_id": (np.ndarray, None), "frequency": (np.ndarray, float), "frequency_unit": (str, None), - "date": (np.ndarray, int), - "orig": (np.ndarray, bool), + "date": (np.ndarray, (int, np.integer)), + "orig": (np.ndarray, (bool, np.bool_)), "unit": (str, None), # For backward compatibility. Replaced by units. "units": (str, None), } From f0c9b675534cfc8923912a274e92e554412aa358 Mon Sep 17 00:00:00 2001 From: Chris Fairless Date: Mon, 4 May 2026 23:11:32 +0200 Subject: [PATCH 6/7] Fixup. It's late I don't know how that typo happened --- climada/hazard/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/climada/hazard/io.py b/climada/hazard/io.py index 0842c5ce42..7307a216cd 100644 --- a/climada/hazard/io.py +++ b/climada/hazard/io.py @@ -33,7 +33,7 @@ import rasterio import xarray as xr from deprecation import deprecated -from scipy import sparsehit_country_per_hazard +from scipy import sparse import climada.util.constants as u_const import climada.util.coordinates as u_coord From 170a2964410f8ab67349948be7a8f89f45413646 Mon Sep 17 00:00:00 2001 From: Chris Fairless Date: Tue, 5 May 2026 00:01:41 +0200 Subject: [PATCH 7/7] Fix the fix: don't allow integer event IDs, better warnings --- climada/hazard/io.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/climada/hazard/io.py b/climada/hazard/io.py index 7307a216cd..679fd6722c 100644 --- a/climada/hazard/io.py +++ b/climada/hazard/io.py @@ -45,11 +45,11 @@ LOGGER = logging.getLogger(__name__) ATTRS_TO_CHECK = { - "event_name": (list, (str, np.str_, int, np.integer)), # int for backward compatibility + "event_name": (list, (str, np.str_)), # int for backward compatibility "event_id": (np.ndarray, None), "frequency": (np.ndarray, float), "frequency_unit": (str, None), - "date": (np.ndarray, (int, np.integer)), + "date": (np.ndarray, (int, np.int64)), "orig": (np.ndarray, (bool, np.bool_)), "unit": (str, None), # For backward compatibility. Replaced by units. "units": (str, None), @@ -706,11 +706,13 @@ def _check_and_cast_elements( # Perform type checking and casting of elements if isinstance(attr_value, (list, np.ndarray)): if not all(isinstance(val, expected_dtype) for val in attr_value): + provided_types = set(type(val) for val in attr_value) warnings.warn( - f"Not all values are of type {expected_dtype}. Casting values.", + f"Not all values are type {expected_dtype}. Provided type(s): {provided_types}. Casting values.", UserWarning, ) - casted_values = [expected_dtype(val) for val in attr_value] + cast_dtype = expected_dtype if not isinstance(expected_dtype, tuple) else expected_dtype[0] + casted_values = [cast_dtype(val) for val in attr_value] # Return the casted values in the same container type if container_type is list: return casted_values