-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(repr): add dispatch for repr of GeoSpatialBinOps
The `GeoUnaryOp`s are already handled by the rules for the parent classes, but the `GeoSpatialBinOps` break because they often have an additional keyword (`distance`) passed in that doesn't get handled by the existing rule for binary operations.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
import ibis | ||
|
||
|
||
@pytest.fixture | ||
def geo_table(): | ||
return ibis.table({"geo1": "geometry", "geo2": "geometry"}, name="t") | ||
|
||
|
||
def test_geospatial_unary_op_repr(geo_table): | ||
expr = geo_table.geo1.centroid() | ||
assert expr.op().name in repr(expr) | ||
|
||
|
||
def test_geospatial_bin_op_repr(geo_table): | ||
expr = geo_table.geo1.d_within(geo_table.geo2, 3.0) | ||
assert expr.op().name in repr(expr) | ||
assert "distance=" in repr(expr) | ||
|
||
|
||
def test_geospatial_bin_op_repr_no_kwarg(geo_table): | ||
expr = geo_table.geo1.distance(geo_table.geo2) | ||
assert expr.op().name in repr(expr) | ||
assert "distance=" not in repr(expr) | ||
# test that there isn't a trailing comma from empty kwargs | ||
assert repr(expr).endswith("r0.geo2)") |