def test_set_frequency_pass(self): """ Test _set_frequency """ bf = BushFire() bf.date = np.array([736167, 736234, 736235]) bf.orig = np.ones(3, bool) bf.event_id = np.arange(3) bf._set_frequency() self.assertTrue(np.allclose(bf.frequency, np.ones(3, float))) bf = BushFire() bf.date = np.array([ 736167, 736167, 736167, 736234, 736234, 736234, 736235, 736235, 736235 ]) bf.orig = np.zeros(9, bool) bf.orig[[0, 3, 6]] = True bf.event_id = np.arange(9) bf._set_frequency() self.assertTrue(np.allclose(bf.frequency, np.ones(9, float) / 3))
def test_random_one_pass(self): """ Test _random_bushfire_one_event """ np.random.seed(8) bf = BushFire() bf.centroids = DEF_CENTROIDS[0] bf.date = np.ones(1) rnd_num = np.random.randint(2, size=1000) bf.intensity = sparse.lil_matrix(np.zeros((1, bf.centroids.size))) bf.intensity[0, :1000] = rnd_num bf.intensity[0, np.logical_not(bf.centroids.on_land)] = 0 bf.intensity = bf.intensity.tocsr() np.random.seed(8) syn_haz = bf._random_bushfire_one_event(0, 5) self.assertTrue(syn_haz.intensity.data.size >= bf.intensity.data.size) self.assertTrue(syn_haz.centroids.area_pixel.sum() >= bf.centroids.area_pixel.sum()) self.assertAlmostEqual(syn_haz.intensity.max(), bf.intensity.max()) self.assertAlmostEqual(syn_haz.intensity.min(), bf.intensity.min())