From 4cdcb1bf866813dd21c4b6f533bed387dda18406 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Thu, 1 Jan 2026 14:07:29 +0100 Subject: [PATCH] TST: fix for proper index comparison --- xvec/tests/conftest.py | 13 +++++++++++++ xvec/tests/test_accessor.py | 8 ++++---- xvec/tests/test_zonal_stats.py | 2 +- xvec/zonal.py | 3 +-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/xvec/tests/conftest.py b/xvec/tests/conftest.py index 6b9dfd2..d101ccd 100644 --- a/xvec/tests/conftest.py +++ b/xvec/tests/conftest.py @@ -196,3 +196,16 @@ def traffic_dataset(geom_array): ) def all_datasets(request): return request.getfixturevalue(request.param) + + +@pytest.fixture( + params=[ + "first_geom_dataset", + "multi_geom_dataset", + "multi_geom_multi_crs_dataset", + "traffic_dataset", + ], + scope="session", +) +def all_geomindex_datasets(request): + return request.getfixturevalue(request.param) diff --git a/xvec/tests/test_accessor.py b/xvec/tests/test_accessor.py index 5054ae6..aa88d96 100644 --- a/xvec/tests/test_accessor.py +++ b/xvec/tests/test_accessor.py @@ -676,8 +676,8 @@ def test_extract_points_array(): ) -def test_cf_roundtrip(all_datasets): - ds = all_datasets +def test_cf_roundtrip(all_geomindex_datasets): + ds = all_geomindex_datasets copy = ds.copy(deep=True) encoded = ds.xvec.encode_cf() @@ -694,8 +694,8 @@ def test_cf_roundtrip(all_datasets): xr.testing.assert_identical(ds, copy) -def test_encode_decode_wkb_roundtrip(all_datasets): - ds = all_datasets +def test_encode_decode_wkb_roundtrip(all_geomindex_datasets): + ds = all_geomindex_datasets encoded = ds.xvec.encode_wkb() for name, da in encoded.coords.items(): if name in ds.xvec._geom_coords_all: diff --git a/xvec/tests/test_zonal_stats.py b/xvec/tests/test_zonal_stats.py index 18b4f48..93f54b4 100644 --- a/xvec/tests/test_zonal_stats.py +++ b/xvec/tests/test_zonal_stats.py @@ -62,7 +62,7 @@ def test_structure(method): }, ).xvec.set_geom_indexes("geometry", crs="EPSG:4326") actual = da.xvec.zonal_stats(polygons, "x", "y", stats="sum", method=method) - xr.testing.assert_identical(actual, expected) + xr.testing.assert_equal(actual, expected) actual_ix = da.xvec.zonal_stats( polygons, "x", "y", stats="sum", method=method, index=True diff --git a/xvec/zonal.py b/xvec/zonal.py index bb22806..a25f2ac 100644 --- a/xvec/zonal.py +++ b/xvec/zonal.py @@ -248,8 +248,7 @@ def _zonal_stats_iterative( crs = None vec_cube = xr.concat( zonal, # type: ignore - # astype('O') is a temporary fix for #87 - dim=xr.DataArray(np.asarray(geometry).astype("O"), name=name, dims=name), + dim=xr.DataArray(geometry, name=name, dims=name), ).xvec.set_geom_indexes(name, crs=crs) gc.collect()