Skip to content

Commit 6363585

Browse files
committed
Add a unit test on Hazard.get_mdr method
1 parent e8dc59b commit 6363585

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

climada/hazard/test/test_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,14 @@ def test_get_mdr(self):
11761176
true_mdr = np.digitize(haz.intensity[:, idx].toarray(), [0, 1])
11771177
np.testing.assert_array_almost_equal(mdr.toarray(), true_mdr)
11781178

1179+
# #case with zeros everywhere
1180+
cent_idx = np.array([0, 0, 1])
1181+
impf.mdd=np.array([0,0,0,1])
1182+
# how many non-zeros values are expected
1183+
num_nz_values = 5
1184+
mdr = haz.get_mdr(cent_idx, impf)
1185+
self.assertEqual(mdr.nnz, num_nz_values)
1186+
11791187
def test_get_paa(self):
11801188
haz = dummy_hazard()
11811189
impf = dummy_step_impf(haz)

0 commit comments

Comments
 (0)