Skip to content
1 change: 1 addition & 0 deletions climada/entity/measures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import numpy as np
import pandas as pd
from geopandas import GeoDataFrame
from scipy.sparse import csr_matrix
Comment thread
peanutfun marked this conversation as resolved.
Outdated

import climada.util.checker as u_check
from climada.entity.exposures.base import INDICATOR_CENTR, INDICATOR_IMPF, Exposures
Expand Down
4 changes: 3 additions & 1 deletion climada/hazard/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def _to_csr_matrix(array: xr.DataArray) -> sparse.csr_matrix:
output_dtypes=[array.dtype],
)
sparse_coo = array.compute().data # Load into memory
return sparse_coo.tocsr() # Convert sparse.COO to scipy.sparse.csr_array
return sparse.csr_matrix(
sparse_coo.tocsr()
) # Convert sparse.COO to scipy.sparse.csr_array
Comment thread
spjuhel marked this conversation as resolved.
Outdated


# Define accessors for xarray DataArrays
Expand Down
Loading