Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
self.df_tessellation["cat"] = list(range(8)) * 18
cat = mm.Simpson(
self.df_tessellation, "cat", self.sw, "uID", categorical=True
).series
assert cat[0] == pytest.approx(0.15)
cat2 = mm.Simpson(
self.df_tessellation,
"cat",
self.sw,
"uID",
categorical=True,
categories=range(15),
).series
assert cat2[0] == pytest.approx(0.15)
self.sw,
"uID",
binning="quantiles",
k=3,
).series
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
)
gs = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
self.df_tessellation["cat"] = list(range(8)) * 18
cat = mm.Simpson(
self.df_tessellation, "cat", self.sw, "uID", categorical=True
).series
assert cat[0] == pytest.approx(0.15)
cat2 = mm.Simpson(
def test_Simpson(self):
ht_sw = mm.Simpson(self.df_tessellation, "area", self.sw, "uID").series
assert ht_sw[0] == 0.385
quan_sw = mm.Simpson(
self.df_tessellation,
self.df_tessellation.area,
self.sw,
"uID",
binning="quantiles",
k=3,
).series
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
)
gs = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
self.df_tessellation["cat"] = list(range(8)) * 18
cat = mm.Simpson(
self.df_tessellation, "cat", self.sw, "uID", categorical=True
).series
assert cat[0] == pytest.approx(0.15)
cat2 = mm.Simpson(
self.df_tessellation,
"cat",
self.sw,
"uID",
categorical=True,
categories=range(15),
).series
assert cat2[0] == pytest.approx(0.15)
def test_Simpson(self):
ht_sw = mm.Simpson(self.df_tessellation, "area", self.sw, "uID").series
assert ht_sw[0] == 0.385
quan_sw = mm.Simpson(
self.df_tessellation,
self.df_tessellation.area,
self.sw,
"uID",
binning="quantiles",
k=3,
).series
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
)
gs = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
self.df_tessellation["cat"] = list(range(8)) * 18
cat = mm.Simpson(
self.df_tessellation, "cat", self.sw, "uID", categorical=True
).series
assert cat[0] == pytest.approx(0.15)
cat2 = mm.Simpson(
self.df_tessellation,
"cat",
self.sw,
"uID",
categorical=True,
def test_Simpson(self):
ht_sw = mm.Simpson(self.df_tessellation, "area", self.sw, "uID").series
assert ht_sw[0] == 0.385
quan_sw = mm.Simpson(
self.df_tessellation,
self.df_tessellation.area,
self.sw,
"uID",
binning="quantiles",
k=3,
).series
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
)
gs = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
assert ht_sw[0] == 0.385
quan_sw = mm.Simpson(
self.df_tessellation,
self.df_tessellation.area,
self.sw,
"uID",
binning="quantiles",
k=3,
).series
assert quan_sw[0] == 0.395
with pytest.raises(ValueError):
ht_sw = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", binning="nonexistent"
)
assert (
mm.Simpson(self.df_tessellation, "area", self.sw_drop, "uID")
.series.isna()
.any()
)
gs = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", gini_simpson=True
).series
assert gs[0] == 1 - 0.385
inv = mm.Simpson(
self.df_tessellation, "area", self.sw, "uID", inverse=True
).series
assert inv[0] == 1 / 0.385
self.df_tessellation["cat"] = list(range(8)) * 18
cat = mm.Simpson(
self.df_tessellation, "cat", self.sw, "uID", categorical=True