Skip to content

Commit

Permalink
Tweaks to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jnclelland committed Nov 30, 2023
1 parent ba3e166 commit 5d96b6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

def test_require_same_crs(square, four_square_grid):
square_gdf = gpd.GeoDataFrame([{"geometry": square}])
square_gdf.crs = "foo"
four_square_grid.crs = "bar"
square_gdf.crs = 4432
four_square_grid.crs = 4433

@require_same_crs
def f(sources, targets):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_indexed_geometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def test_indexed_has_a_spatial_index(four_square_grid):
def test_indexed_queries_its_spatial_index_when_intersections_is_called(
four_square_grid, square
):
with patch("maup.indexed_geometries.STRtree") as SpatialIndex:
spatial_index = SpatialIndex.return_value
with patch("maup.indexed_geometries.STRtree.query",) as query_fn:
query_fn.return_value = np.array([])
IndexedGeometries(four_square_grid).intersections(square)
spatial_index.query.assert_called()
query_fn.assert_called()


def test_intersections_correct_when_all_overlapping(four_square_grid, square):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def test_example_autorepair_MI():
assert holes.unary_union.area > 100
assert len(holes) > 0

shp["geometry"] = maup.autorepair(shp, relative_threshold=None)
shp["geometry"] = maup.quick_repair(shp, relative_threshold=None)

assert count_overlaps(shp) == 0
holes = maup.repair.holes_of_union(shp)
assert holes.empty or holes.unary_union.area < 1e-10 # overlaps are not guaranteed to disappear
assert maup.doctor(shp)
# This assertion is a terrible idea since there will almost certainly still be small
# gaps and overlaps remaining!
# assert maup.doctor(shp)

def test_snap_shp_to_grid():
shp = geopandas.read_file("zip://./examples/MI.zip") # MI shapefile
Expand Down

0 comments on commit 5d96b6a

Please sign in to comment.