Skip to content

Commit

Permalink
Update test_base_xarray.py
Browse files Browse the repository at this point in the history
adapted event_name in test_assert_default_values and deleted event_name tests from test_missing_dims since the time dimension does not affect event_name anymore
  • Loading branch information
sarah-hlsn committed Oct 23, 2023
1 parent b54a62f commit 661b2c0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions climada/hazard/test/test_base_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _assert_default_values(self, hazard):
self.assertEqual(hazard.units, "")
np.testing.assert_array_equal(hazard.event_id, [1, 2])
np.testing.assert_array_equal(
hazard.event_name, [np.datetime64(val) for val in self.time]
hazard.event_name, [str(x) for x in hazard.event_id]
)
np.testing.assert_array_equal(
hazard.date, [val.toordinal() for val in self.time]
Expand Down Expand Up @@ -342,9 +342,7 @@ def test_missing_dims(self):
ds = ds.isel(time=0).squeeze()
hazard = Hazard.from_xarray_raster(ds, "", "")
self._assert_default_types(hazard)
np.testing.assert_array_equal(
hazard.event_name, [np.datetime64(self.time[0])]
)

np.testing.assert_array_equal(hazard.date, [self.time[0].toordinal()])
np.testing.assert_array_equal(hazard.centroids.lat, [0, 0, 0, 1, 1, 1])
np.testing.assert_array_equal(hazard.centroids.lon, [0, 1, 2, 0, 1, 2])
Expand All @@ -369,9 +367,6 @@ def test_missing_dims(self):
ds = ds.expand_dims(time=[np.datetime64("2022-01-01")])
hazard = Hazard.from_xarray_raster(ds, "", "")
self._assert_default_types(hazard)
np.testing.assert_array_equal(
hazard.event_name, [np.datetime64("2022-01-01")]
)
np.testing.assert_array_equal(
hazard.date, [dt.datetime(2022, 1, 1).toordinal()]
)
Expand Down

0 comments on commit 661b2c0

Please sign in to comment.