Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions xvec/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,14 @@ def sel(
# (see https://github.com/pydata/xarray/issues/7099)
return self._sel_sindex(labels, method, tolerance) # type: ignore

def equals(self, other: Index) -> bool:
def equals(
self, other: Index, *, exclude: frozenset[Hashable] | None = None
) -> bool:
if not isinstance(other, GeometryIndex):
return False
if not self._check_crs(other.crs, allow_none=True):
return False
return self._index.equals(other._index)
return self._index.equals(other._index, exclude=exclude)

def join(
self: GeometryIndex, other: GeometryIndex, how: str = "inner"
Expand Down
24 changes: 15 additions & 9 deletions xvec/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def glaciers():
)


@image_comparison(baseline_images=["col"], extensions=["png"], style=[])
@image_comparison(baseline_images=["col"], extensions=["png"], style=[], tol=0.01)
def test_col(aggregated):
f, ax = aggregated.v.sel(month=1).xvec.plot(col="level")

Expand All @@ -48,7 +48,7 @@ def test_col(aggregated):
assert ax0.get_title() == "level = 200"


@image_comparison(baseline_images=["colwrap"], extensions=["png"], style=[])
@image_comparison(baseline_images=["colwrap"], extensions=["png"], style=[], tol=0.01)
def test_colwrap(aggregated):
f, ax = aggregated.u.sel(month=1).xvec.plot(col="level", col_wrap=2)

Expand All @@ -58,7 +58,7 @@ def test_colwrap(aggregated):
assert ax[0][0].get_title() == "level = 200"


@image_comparison(baseline_images=["col_row"], extensions=["png"], style=[])
@image_comparison(baseline_images=["col_row"], extensions=["png"], style=[], tol=0.01)
def test_col_row(aggregated):
f, ax = aggregated.v.xvec.plot(col="month", row="level")

Expand All @@ -70,15 +70,15 @@ def test_col_row(aggregated):
assert ax[0][1].get_ylabel() == "level = 200"


@image_comparison(baseline_images=["1d"], extensions=["png"], style=[])
@image_comparison(baseline_images=["1d"], extensions=["png"], style=[], tol=0.01)
def test_1d(aggregated):
f, ax = aggregated.z.sel(level=200, month=1).xvec.plot()

assert ax.get_xlabel() == "Geodetic longitude\n[degree]"
assert ax.get_ylabel() == "Geodetic latitude\n[degree]"


@image_comparison(baseline_images=["var_geom"], extensions=["png"], style=[])
@image_comparison(baseline_images=["var_geom"], extensions=["png"], style=[], tol=0.01)
def test_var_geom(glaciers):
f, ax = glaciers.geometry.xvec.plot(col="year")

Expand All @@ -89,7 +89,9 @@ def test_var_geom(glaciers):
assert ax0.get_title() == "year = 1936.0"


@image_comparison(baseline_images=["var_geom_facet"], extensions=["png"], style=[])
@image_comparison(
baseline_images=["var_geom_facet"], extensions=["png"], style=[], tol=0.01
)
def test_var_geom_facet(glaciers):
f, ax = glaciers.geometry.xvec.plot(col="name", row="year")

Expand All @@ -100,7 +102,9 @@ def test_var_geom_facet(glaciers):
assert ax[0][-1].get_ylabel() == "year = 1936.0"


@image_comparison(baseline_images=["var_geom_ds"], extensions=["png"], style=[])
@image_comparison(
baseline_images=["var_geom_ds"], extensions=["png"], style=[], tol=0.01
)
def test_var_geom_ds(glaciers):
f, ax = glaciers.xvec.plot(col="year", geometry="geometry")

Expand All @@ -111,7 +115,7 @@ def test_var_geom_ds(glaciers):
assert ax0.get_title() == "year = 1936.0"


@image_comparison(baseline_images=["hue"], extensions=["png"], style=[])
@image_comparison(baseline_images=["hue"], extensions=["png"], style=[], tol=0.01)
def test_hue(glaciers):
f, ax = glaciers.xvec.plot(col="year", geometry="geometry", hue="fwidth")

Expand All @@ -122,7 +126,9 @@ def test_hue(glaciers):
assert ax0.get_title() == "year = 1936.0"


@image_comparison(baseline_images=["geom_switching"], extensions=["png"], style=[])
@image_comparison(
baseline_images=["geom_switching"], extensions=["png"], style=[], tol=0.01
)
def test_geom_switching(glaciers):
glaciers_w_sum = glaciers.xvec.summarize_geometry(
dim="name", geom_array="geometry", aggfunc="concave_hull", ratio=0.25
Expand Down