|
28 | 28 | import numpy as np |
29 | 29 | import xarray as xr |
30 | 30 | from pyproj import CRS |
31 | | -from scipy.sparse import csr_matrix |
| 31 | +from scipy.sparse import csr_array, csr_matrix |
32 | 32 |
|
33 | 33 | from climada.hazard.base import Hazard |
34 | 34 | from climada.util.constants import DEF_CRS |
@@ -104,8 +104,8 @@ def _assert_default_types(self, hazard): |
104 | 104 | self.assertIsInstance(hazard.event_id, np.ndarray) |
105 | 105 | self.assertIsInstance(hazard.event_name, list) |
106 | 106 | self.assertIsInstance(hazard.frequency, np.ndarray) |
107 | | - self.assertIsInstance(hazard.intensity, csr_matrix) |
108 | | - self.assertIsInstance(hazard.fraction, csr_matrix) |
| 107 | + self.assertIsInstance(hazard.intensity, csr_matrix | csr_array) |
| 108 | + self.assertIsInstance(hazard.fraction, csr_matrix | csr_array) |
109 | 109 | self.assertIsInstance(hazard.date, np.ndarray) |
110 | 110 |
|
111 | 111 | def test_load_path(self): |
@@ -149,8 +149,11 @@ def _load_and_assert(**kwargs): |
149 | 149 | def test_type_error(self): |
150 | 150 | """Calling 'from_xarray_raster' with wrong data type should throw""" |
151 | 151 | # Passing a DataArray |
152 | | - with xr.open_dataset(self.netcdf_path) as dset, self.assertRaisesRegex( |
153 | | - TypeError, "This method only supports passing xr.Dataset" |
| 152 | + with ( |
| 153 | + xr.open_dataset(self.netcdf_path) as dset, |
| 154 | + self.assertRaisesRegex( |
| 155 | + TypeError, "This method only supports passing xr.Dataset" |
| 156 | + ), |
154 | 157 | ): |
155 | 158 | Hazard.from_xarray_raster(dset["intensity"], "", "") |
156 | 159 |
|
|
0 commit comments