How to use the momepy.Shannon function in momepy

To help you get started, we’ve selected a few momepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github martinfleis / momepy / tests / test_diversity.py View on Github external
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,
github martinfleis / momepy / tests / test_diversity.py View on Github external
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)
github martinfleis / momepy / tests / test_diversity.py View on Github external
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")
github martinfleis / momepy / tests / test_diversity.py View on Github external
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,
github martinfleis / momepy / tests / test_diversity.py View on Github external
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)
github martinfleis / momepy / tests / test_diversity.py View on Github external
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()