Skip to content

Commit 8401e60

Browse files
authored
TST: fix for proper index comparison (#137)
1 parent 8cc8ad1 commit 8401e60

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

xvec/tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,16 @@ def traffic_dataset(geom_array):
196196
)
197197
def all_datasets(request):
198198
return request.getfixturevalue(request.param)
199+
200+
201+
@pytest.fixture(
202+
params=[
203+
"first_geom_dataset",
204+
"multi_geom_dataset",
205+
"multi_geom_multi_crs_dataset",
206+
"traffic_dataset",
207+
],
208+
scope="session",
209+
)
210+
def all_geomindex_datasets(request):
211+
return request.getfixturevalue(request.param)

xvec/tests/test_accessor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ def test_extract_points_array():
676676
)
677677

678678

679-
def test_cf_roundtrip(all_datasets):
680-
ds = all_datasets
679+
def test_cf_roundtrip(all_geomindex_datasets):
680+
ds = all_geomindex_datasets
681681
copy = ds.copy(deep=True)
682682
encoded = ds.xvec.encode_cf()
683683

@@ -694,8 +694,8 @@ def test_cf_roundtrip(all_datasets):
694694
xr.testing.assert_identical(ds, copy)
695695

696696

697-
def test_encode_decode_wkb_roundtrip(all_datasets):
698-
ds = all_datasets
697+
def test_encode_decode_wkb_roundtrip(all_geomindex_datasets):
698+
ds = all_geomindex_datasets
699699
encoded = ds.xvec.encode_wkb()
700700
for name, da in encoded.coords.items():
701701
if name in ds.xvec._geom_coords_all:

xvec/tests/test_zonal_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_structure(method):
6262
},
6363
).xvec.set_geom_indexes("geometry", crs="EPSG:4326")
6464
actual = da.xvec.zonal_stats(polygons, "x", "y", stats="sum", method=method)
65-
xr.testing.assert_identical(actual, expected)
65+
xr.testing.assert_equal(actual, expected)
6666

6767
actual_ix = da.xvec.zonal_stats(
6868
polygons, "x", "y", stats="sum", method=method, index=True

xvec/zonal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ def _zonal_stats_iterative(
248248
crs = None
249249
vec_cube = xr.concat(
250250
zonal, # type: ignore
251-
# astype('O') is a temporary fix for #87
252-
dim=xr.DataArray(np.asarray(geometry).astype("O"), name=name, dims=name),
251+
dim=xr.DataArray(geometry, name=name, dims=name),
253252
).xvec.set_geom_indexes(name, crs=crs)
254253
gc.collect()
255254

0 commit comments

Comments
 (0)