Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GeoPandas tests for new functions/args raise warning and not fail in CI #403

Merged
merged 3 commits into from
Sep 23, 2023
Merged
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
28 changes: 19 additions & 9 deletions tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ def test_geopandas_coverage(self) -> None:
# Check that all methods declared in the class above are covered in Vector
list_missing = [method for method in covered_methods if method not in self.all_declared]

assert len(list_missing) == 0, print(f"Missing methods from GeoPandas: {list_missing}")
if len(list_missing) != 0:
warnings.warn(f"New GeoPandas methods are not implemented in GeoUtils: {list_missing}")

@pytest.mark.parametrize("method", nongeo_methods + geo_methods) # type: ignore
def test_overridden_funcs_args(self, method: str) -> None:
Expand All @@ -725,12 +726,19 @@ def test_overridden_funcs_args(self, method: str) -> None:
argspec_geoutils = inspect.getfullargspec(getattr(gu.Vector, method))

# Check that all positional arguments are the same
assert argspec_upstream.args == argspec_geoutils.args
if argspec_upstream.args != argspec_geoutils.args:
warnings.warn("Argument of GeoPandas method not consistent in GeoUtils.")

# Check that the *args and **kwargs argument are declared consistently
assert argspec_upstream.varargs == argspec_geoutils.varargs
assert argspec_upstream.varkw == argspec_geoutils.varkw
if argspec_upstream.varargs != argspec_geoutils.varargs:
warnings.warn("Argument of GeoPandas method not consistent in GeoUtils.")

if argspec_upstream.varkw != argspec_geoutils.varkw:
warnings.warn("Argument of GeoPandas method not consistent in GeoUtils.")

# Check that default argument values are the same
assert argspec_upstream.defaults == argspec_geoutils.defaults
if argspec_upstream.defaults != argspec_geoutils.defaults:
warnings.warn("Default argument of GeoPandas method not consistent in GeoUtils.")

@pytest.mark.parametrize("vector", [synthvec1, synthvec2, realvec1, realvec2]) # type: ignore
@pytest.mark.parametrize("method", nongeo_properties) # type: ignore
Expand Down Expand Up @@ -821,7 +829,7 @@ def test_geo_properties(self, vector: gu.Vector, method: str) -> None:
@pytest.mark.parametrize("vector2", [synthvec2, realvec2]) # type: ignore
@pytest.mark.parametrize("method", geo_methods) # type: ignore
def test_geo_methods(self, vector1: gu.Vector, vector2: gu.Vector, method: str) -> None:
"""Check geometric properties are consistent with GeoPandas."""
"""Check geometric methods are consistent with GeoPandas."""

# Remove warnings about operations in a non-projected system, and future changes
warnings.simplefilter("ignore", category=UserWarning)
Expand Down Expand Up @@ -856,9 +864,11 @@ def test_geo_methods(self, vector1: gu.Vector, vector2: gu.Vector, method: str)
# Separate cases depending on GeoPandas' output, and nature of the function
# Simplify is a special case that can make geometries invalid, so adjust test
if method == "simplify":
assert_geoseries_equal(
output_geopandas.make_valid(), output_geoutils.ds.geometry.make_valid(), check_less_precise=True
)
# TODO: Unskip this random test failure (one index not matching) when this is fixed in GeoPandas/Shapely
pass
# assert_geoseries_equal(
# output_geopandas.make_valid(), output_geoutils.ds.geometry.make_valid(), check_less_precise=True
# )
# For geoseries output, check equality of it
elif isinstance(output_geopandas, gpd.GeoSeries):
assert_geoseries_equal(output_geoutils.ds.geometry, output_geopandas)
Expand Down