How to use maup - 10 common examples

To help you get started, we’ve selected a few maup 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 mggg / maup / tests / test_intersections.py View on Github external
def test_returns_geoseries_with_multiindex(self, sources, targets):
        result = intersections(sources, targets)

        assert isinstance(result, geopandas.GeoSeries)
        assert isinstance(result.index, pandas.MultiIndex)
github mggg / maup / tests / test_intersections.py View on Github external
def test_gives_expected_index(self, sources, targets_with_str_index):
        expected = manually_compute_intersections(sources, targets_with_str_index)
        result = intersections(sources, targets_with_str_index)
        they_match = result.index == expected.index
        assert they_match.all()
github mggg / maup / tests / test_intersections.py View on Github external
def test_works_with_non_range_index(self, sources, targets_with_str_index):
        result = intersections(sources, targets_with_str_index)
        assert isinstance(result, geopandas.GeoSeries)
        assert isinstance(result.index, pandas.MultiIndex)
github mggg / maup / tests / test_intersections.py View on Github external
def test_indexed_by_source_then_target(self, sources, targets_with_str_index):
        result = intersections(sources, targets_with_str_index)
        assert (result.index.levels[0] == sources.index).all()
        assert (result.index.levels[1] == targets_with_str_index.index).all()
github mggg / maup / tests / test_intersections.py View on Github external
def test_expected_intersections(self, sources, targets_with_str_index):
        expected = manually_compute_intersections(sources, targets_with_str_index)
        result = intersections(sources, targets_with_str_index)
        assert (result == expected).all()
github mggg / maup / tests / test_intersections.py View on Github external
def test_sets_crs(self, sources, targets):
        crs = sources.crs
        assert crs
        inters = intersections(sources, targets)
        assert inters.crs == crs
github mggg / maup / tests / test_assign.py View on Github external
def test_gives_same_answer_for_integer_indices(self, four_square_grid, squares_df):
        assignment = assign_by_area(squares_df, four_square_grid)
        expected = assign_by_covering(squares_df, four_square_grid)
        assert (expected == assignment).all()
github mggg / maup / tests / test_assign.py View on Github external
def test_assign_by_area_dispatches_to_non_integer_version(
        self, four_square_grid, squares_df
    ):
        targets = four_square_grid.set_index("ID")
        sources = squares_df.set_index("ID")
        assignment = assign_by_area(sources, targets)
        expected = assign_by_covering(sources, targets)
        assert (expected == assignment).all()
github mggg / maup / tests / test_assign.py View on Github external
def test_assign_can_be_used_with_groupby(four_square_grid, squares_df):
    assignment = assign_by_covering(squares_df, four_square_grid.set_index("ID"))

    result = squares_df.groupby(assignment)

    assert set(result.groups.keys()) == {"a", "b", "d"}
    assert set(result.indices["a"]) == {0, 1}
    assert set(result.indices["b"]) == {2}
    assert set(result.indices["d"]) == {3}
github mggg / maup / tests / test_assign.py View on Github external
def test_assign_gives_expected_answer_when_geoms_nest_neatly(
    four_square_grid, squares_within_four_square_grid
):
    result = set(
        assign_by_covering(
            squares_within_four_square_grid, four_square_grid.set_index("ID")
        ).items()
    )

    assert result == {(0, "a"), (1, "a"), (2, "b"), (3, "d")}