Skip to content

Commit

Permalink
Fix misplaced assert
Browse files Browse the repository at this point in the history
  • Loading branch information
fbunt committed Jun 27, 2024
1 parent ab3bb0a commit 4809e4e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion raster_tools/line_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def length(features, like_rast, radius, weighting_field=None):
data = da.overlap.trim_internal(
data, axes={0: 0, 1: ydepth, 2: xdepth}, boundary=1
)
assert data.chunks == like_rast.data.chunks
data = da.sum(data, axis=0, keepdims=True)
assert data.chunks == like_rast.data.chunks
xrs = xr.DataArray(
data, dims=("band", "y", "x"), coords=([1], like_rast.y, like_rast.x)
)
Expand Down
32 changes: 32 additions & 0 deletions tests/test_line_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# isort: on

import dask_geopandas as dgpd
import geopandas as gpd
import numpy as np
import pytest
Expand Down Expand Up @@ -239,6 +240,37 @@ def like_template(template, data):
),
True,
),
(
dgpd.from_geopandas(
gpd.GeoDataFrame(
{
"weights": [3, 4],
"geometry": [
LineString([(0, 3), (2, 3)]),
LineString([(2, 3), (2, 0)]),
],
},
crs="EPSG:5070",
),
npartitions=2,
),
Raster(template_44).chunk((1, 2, 2)),
1,
Raster(
like_template(
template_44,
np.array(
[
[3, 6, 7, 0],
[0, 0, 8, 0],
[0, 0, 8, 0],
[0, 0, 4, 0],
]
),
)
),
True,
),
],
)
def test_length(geoms, like, radius, truth, weight):
Expand Down

0 comments on commit 4809e4e

Please sign in to comment.