diff --git a/climada/entity/exposures/base.py b/climada/entity/exposures/base.py index c7e25604e..fec6499ae 100644 --- a/climada/entity/exposures/base.py +++ b/climada/entity/exposures/base.py @@ -996,7 +996,9 @@ def concat(exposures_list): ] crss = [ ex.crs for ex in exposures_list - if isinstance(ex, (Exposures, GeoDataFrame)) and not ex.crs is None + if isinstance(ex, (Exposures, GeoDataFrame)) + and hasattr(ex, "crs") + and ex.crs is not None ] if crss: crs = crss[0] diff --git a/climada/entity/exposures/test/test_base.py b/climada/entity/exposures/test/test_base.py index cad29cee7..c321ca08f 100644 --- a/climada/entity/exposures/test/test_base.py +++ b/climada/entity/exposures/test/test_base.py @@ -447,7 +447,7 @@ def test_set_gdf(self): probe.set_gdf(empty_gdf) self.assertTrue(probe.gdf.equals(gpd.GeoDataFrame())) self.assertTrue(u_coord.equal_crs(DEF_CRS, probe.crs)) - self.assertIsNone(probe.gdf.crs) + self.assertFalse(hasattr(probe.gdf, "crs")) probe.set_gdf(gdf_with_geometry) self.assertTrue(probe.gdf.equals(gdf_with_geometry)) @@ -457,7 +457,7 @@ def test_set_gdf(self): probe.set_gdf(gdf_without_geometry) self.assertTrue(probe.gdf.equals(good_exposures().gdf)) self.assertTrue(u_coord.equal_crs(DEF_CRS, probe.crs)) - self.assertIsNone(probe.gdf.crs) + self.assertFalse(hasattr(probe.gdf, "crs")) def test_set_crs(self): """Test setting the CRS""" diff --git a/climada/entity/measures/test/test_base.py b/climada/entity/measures/test/test_base.py index 62ff2f31e..3fc7e8a98 100644 --- a/climada/entity/measures/test/test_base.py +++ b/climada/entity/measures/test/test_base.py @@ -280,7 +280,8 @@ def test_filter_exposures_pass(self): self.assertEqual(res_exp.tag.file_name, exp.tag.file_name) self.assertEqual(res_exp.tag.description, exp.tag.description) self.assertTrue(u_coord.equal_crs(res_exp.crs, exp.crs)) - self.assertTrue(u_coord.equal_crs(res_exp.gdf.crs, exp.gdf.crs)) + self.assertFalse(hasattr(exp.gdf, "crs")) + self.assertFalse(hasattr(res_exp.gdf, "crs")) # regions (that is just input data, no need for testing, but it makes the changed and unchanged parts obious) self.assertTrue(np.array_equal(res_exp.gdf.region_id.values[0], 4)) diff --git a/climada/util/test/test_coordinates.py b/climada/util/test/test_coordinates.py index 60400befa..71292ac31 100644 --- a/climada/util/test/test_coordinates.py +++ b/climada/util/test/test_coordinates.py @@ -1191,7 +1191,7 @@ def test_points_to_raster_pass(self): df_val['value'] = np.ones(len(df_val)) * 10 crs = 'epsg:2202' _raster, meta = u_coord.points_to_raster(df_val, val_names=['value'], crs=crs) - self.assertIsNone(df_val.crs) # points_to_raster must not modify df_val + self.assertFalse(hasattr(df_val, "crs")) # points_to_raster must not modify df_val self.assertTrue(u_coord.equal_crs(meta['crs'], crs)) self.assertAlmostEqual(meta['transform'][0], 0.5) self.assertAlmostEqual(meta['transform'][1], 0)