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

DEP: GeoSeries.geom_almost_equals #2604

Closed
wants to merge 26 commits into from
Closed

Conversation

darshanip
Copy link
Contributor

@darshanip darshanip commented Oct 18, 2022

Fixes #2538

Need confirmation, apart from the deletion I did do we need to remove 'geom_almost_equals' and its usages as well?
This is first code contribution in OS.

@darshanip
Copy link
Contributor Author

hi @m-richards , could you please check on this.

@m-richards
Copy link
Member

Hi @darshanip, this is unused code so is good to delete. With geom_almost_equals, we won't remove that yet, but should rather add a FutureWarning to indicate to users it will be removed in a future version.

The warnings removed in #2267 are an example of the kind of message you should add here if you'd like some guidance.

Due to linter error.
geopandas/base.py:1100:89: E501 line too long (91 > 88 characters)
geopandas/array.py:573:89: E501 line too long (91 > 88 characters)
@darshanip
Copy link
Contributor Author

darshanip commented Nov 3, 2022

@m-richards Could you please review the changes.

@darshanip
Copy link
Contributor Author

@jorisvandenbossche @martinfleis, Could you please review changes.

Copy link
Member

@m-richards m-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @darshanip, sorry for the delayed response.

This is looking good so far but there is a little bit more to do:

  • We should update the tests using geom_almost_equals to use geom_equals_exact instead and the helper method in testing.py
  • In test_geoseries::test_geom_almost_equals we should add a test to check the correct warning is emitted, and filter the warning from the other usages.
  • We should update the documentation in data_structures.rst to refer to geom_equals_exact instead.

geopandas/array.py Outdated Show resolved Hide resolved
geopandas/base.py Outdated Show resolved Hide resolved
darshanip and others added 5 commits November 15, 2022 01:11
- Updated shapely warning
- Updated tests using geom_almost_equals to geom_equals_exact
- Updated documentaion in data_structures.rst to refer geom_equals_exact instead.

Pending - New test required for correct warning.
for 88 chars
@darshanip
Copy link
Contributor Author

@m-richards can you please review code.

Copy link
Member

@m-richards m-richards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @darshanip, I've left a handful of further comments which should help with fixing some of the test errors.

geopandas/array.py Outdated Show resolved Hide resolved
doc/source/docs/user_guide/data_structures.rst Outdated Show resolved Hide resolved
geopandas/base.py Outdated Show resolved Hide resolved
geopandas/testing.py Outdated Show resolved Hide resolved
geopandas/testing.py Outdated Show resolved Hide resolved
@@ -61,7 +61,7 @@ def expected_mean(merged_shapes):
def test_geom_dissolve(nybb_polydf, first):
test = nybb_polydf.dissolve("manhattan_bronx")
assert test.geometry.name == "myshapes"
assert test.geom_almost_equals(first).all()
assert test.geom_equals_exact(first).all()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be updated to provide the second parameter for geom_equals_exact

geopandas/tests/test_geom_methods.py Outdated Show resolved Hide resolved
geopandas/tests/test_geoseries.py Outdated Show resolved Hide resolved
geopandas/base.py Outdated Show resolved Hide resolved
darshanip and others added 5 commits May 2, 2023 18:25
Co-authored-by: Matt Richards <45483497+m-richards@users.noreply.github.com>
Co-authored-by: Matt Richards <45483497+m-richards@users.noreply.github.com>
Co-authored-by: Matt Richards <45483497+m-richards@users.noreply.github.com>
Co-authored-by: Matt Richards <45483497+m-richards@users.noreply.github.com>
Co-authored-by: Matt Richards <45483497+m-richards@users.noreply.github.com>
geopandas/testing.py Outdated Show resolved Hide resolved
@m-richards m-richards changed the title DEP: GeoSeries.almost_equals DEP: GeoSeries.geom_almost_equals Jul 23, 2023
@m-richards
Copy link
Member

I've revived this, should be close to ready now. I'm not sure if we should also deprecate geopandas.testing.geom_almost_equals. I don't really see a huge issue with keeping it. If we were to deprecate, it would definitely be worth keeping a private internal helper for this.

Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I'm not sure if we should also deprecate geopandas.testing.geom_almost_equals.

Fine with keeping it as well.

CHANGELOG.md Outdated Show resolved Hide resolved
@martinfleis martinfleis added this to the 0.14 milestone Jul 26, 2023
m-richards and others added 2 commits August 9, 2023 22:05
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot add a warning on both the array level and the base level as the warning is then emitted twice if the method is accessed from GeoSeries/DataFrame.

In [2]: from geodatasets import get_path

In [3]: df = geopandas.read_file(get_path('nybb'))

In [4]: df.geom_almost_equals(df)
<ipython-input-4-6eaa63e61711>:1: FutureWarning: The 'geom_almost_equals()' method is deprecated because the name isconfusing. The 'geom_equals_exact()' method should be used instead.
  df.geom_almost_equals(df)
/Users/martin/Git/geopandas/geopandas/base.py:47: FutureWarning: The 'geom_almost_equals()' method is deprecated because the name isconfusing. The 'geom_equals_exact()' method should be used instead.
  data = getattr(a_this, op)(other, *args, **kwargs)

We should have it one one level only, probably on array. We could also keep it on both level but use geom_equals_exact array-level method in base-level geom_almost_equals.

@martinfleis martinfleis modified the milestones: 0.14, 1.0 Sep 13, 2023
@m-richards
Copy link
Member

We should have it one one level only, probably on array. We could also keep it on both level but use geom_equals_exact array-level method in base-level geom_almost_equals.

I've done the latter, it seems better to keep the warning in base.py so the stacklevel is correct for an end user.

@m-richards
Copy link
Member

@martinfleis I've had to continue this at #3017 as I seem to no longer have push permissions on the fork.

@martinfleis
Copy link
Member

Superseded by #3017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate GeoSeries.almost_equals (deprecated in shapely)
3 participants