@@ -215,3 +215,33 @@ def test_hazard_forecast_mean_min_max(haz_fc):
215215 assert np .all (haz_fcst_mean .orig )
216216 assert np .all (haz_fcst_min .orig )
217217 assert np .all (haz_fcst_max .orig )
218+
219+
220+ def test_hazard_forecast_quantile (haz_fc ):
221+ """Check quantile method for HazardForecast"""
222+ for q in [0.0 , 0.5 , 0.8 ]:
223+ haz_fcst_quantile = haz_fc .quantile (q )
224+
225+ # assert intensity
226+ npt .assert_array_equal (
227+ haz_fcst_quantile .intensity .toarray ().squeeze (),
228+ np .quantile (haz_fc .intensity .toarray (), q , axis = 0 ),
229+ )
230+ # assert fraction
231+ npt .assert_array_equal (
232+ haz_fcst_quantile .fraction .toarray ().squeeze (),
233+ np .quantile (haz_fc .fraction .toarray (), q , axis = 0 ),
234+ )
235+
236+ # check that attributes where reduced correctly
237+ npt .assert_array_equal (
238+ haz_fcst_quantile .lead_time , np .array ([np .timedelta64 ("NaT" )])
239+ )
240+ npt .assert_array_equal (haz_fcst_quantile .member , np .array ([- 1 ]))
241+ npt .assert_array_equal (
242+ haz_fcst_quantile .event_name , np .array ([f"quantile_{ q } " ])
243+ )
244+ npt .assert_array_equal (haz_fcst_quantile .event_id , np .array ([0 ]))
245+ npt .assert_array_equal (haz_fcst_quantile .frequency , np .array ([1 ]))
246+ npt .assert_array_equal (haz_fcst_quantile .date , np .array ([0 ]))
247+ npt .assert_array_equal (haz_fcst_quantile .orig , np .array ([True ]))
0 commit comments