def test_Shannon(self): ht_sw = mm.Shannon(self.df_tessellation, "area", self.sw, "uID").series assert ht_sw[0] == 1.094056456831614 quan_sw = mm.Shannon( self.df_tessellation, self.df_tessellation.area, self.sw, "uID", binning="quantiles", k=3, ).series assert quan_sw[0] == 0.9985793315873921 with pytest.raises(ValueError): ht_sw = mm.Shannon(self.df_tessellation, "area", self.sw, "uID", binning="nonexistent") assert (mm.Shannon(self.df_tessellation, "area", self.sw_drop, "uID").series.isna().any()) self.df_tessellation["cat"] = list(range(8)) * 18 cat = mm.Shannon(self.df_tessellation, "cat", self.sw, "uID", categorical=True).series assert cat[0] == pytest.approx(1.973) cat2 = mm.Shannon( self.df_tessellation, "cat", self.sw, "uID", categorical=True, categories=range(15), ).series assert cat2[0] == pytest.approx(1.973)
def time_Shannon(self, binning): mm.Shannon(self.df_tessellation, "area", self.sw, "uID", binning)