From e6f4ec65c5fb6d425ee041264947b7726c6db371 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Thu, 16 Apr 2026 22:29:10 +0200 Subject: [PATCH 1/3] fix: backwards compatibility of aggregate_matrix --- atlite/aggregate.py | 7 ++++++- atlite/convert.py | 2 +- atlite/gis.py | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/atlite/aggregate.py b/atlite/aggregate.py index 44464c2e..eb100260 100644 --- a/atlite/aggregate.py +++ b/atlite/aggregate.py @@ -5,14 +5,19 @@ Functions for aggregating results. """ +import pandas as pd import scipy.sparse as sp import xarray as xr from dask.array.core import Array +from atlite.utils import ensure_coords + def aggregate_matrix( - da: xr.DataArray, matrix: sp.csr_matrix, coords: xr.Coordinates + da: xr.DataArray, matrix: sp.csr_matrix, index: xr.Coordinates | pd.Index ) -> xr.DataArray: + coords = ensure_coords(index) + if isinstance(da.data, Array): da = da.stack(spatial=("y", "x")) da = da.chunk(dict(spatial=-1)) diff --git a/atlite/convert.py b/atlite/convert.py index fab5628e..b1f0fcc1 100644 --- a/atlite/convert.py +++ b/atlite/convert.py @@ -254,7 +254,7 @@ def convert_and_aggregate( coords = ensure_coords(pd.RangeIndex(matrix.shape[0]) if index is None else index) if len(coords.dims) > 1: raise ValueError(f"index must have a single dimension, not: {coords.dims}") - results = aggregate_matrix(da, matrix=matrix, coords=coords) + results = aggregate_matrix(da, matrix=matrix, index=coords) if per_unit or return_capacity: caps = matrix.sum(-1) diff --git a/atlite/gis.py b/atlite/gis.py index 6b7edb56..0d76eef8 100644 --- a/atlite/gis.py +++ b/atlite/gis.py @@ -479,7 +479,9 @@ def open_files(self): assert isinstance(raster, rio.DatasetReader) # Check if the raster has a valid CRS - if not (raster.crs.is_geographic or raster.crs.is_projected): + if raster.crs is None or not ( + raster.crs.is_geographic or raster.crs.is_projected + ): if d["crs"]: raster._crs = CRS(d["crs"]) else: From e6980892506008e0c1679f17ba924ce5a92cfe33 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Fri, 17 Apr 2026 00:41:30 +0200 Subject: [PATCH 2/3] fix: convert lil to csr form --- atlite/convert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atlite/convert.py b/atlite/convert.py index b1f0fcc1..fb626e9b 100644 --- a/atlite/convert.py +++ b/atlite/convert.py @@ -237,7 +237,7 @@ def convert_and_aggregate( if isinstance(shapes, geoseries_like) and index is None: index = shapes.index - matrix = cutout.indicatormatrix(shapes, shapes_crs) + matrix = cutout.indicatormatrix(shapes, shapes_crs).tocsr() if layout is not None: assert isinstance(layout, xr.DataArray) From 3299869f809d8a016853e7f28819e494c578cb51 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Tue, 21 Apr 2026 10:23:53 +0200 Subject: [PATCH 3/3] docs: add release note --- RELEASE_NOTES.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 06dde4df..1583d28c 100755 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -17,8 +17,15 @@ Upcoming Release To use the features already you have to install the ``master`` branch, e.g. ``pip install git+https://github.com/pypsa/atlite``. +`v0.6.1 `__ (21st April 2026) +======================================================================================= + +**Bug fixes** + +* Fix backwards compatibility of ``aggregate_matrix``. + `v0.6.0 `__ (15th April 2026) -======================================================================================= +======================================================================================= **Features**