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

Rename shapely.apply to shapely.transform #1393

Merged
merged 4 commits into from
Jun 19, 2022

Conversation

jorisvandenbossche
Copy link
Member

xref #1276 about naming inconsistencies

Shapely uses "transform" for what is called apply for the vectorized functions (merged from pygeos). This PR renames apply() to transform().

I personally think both names are fine, so this change keeps it a bit more consistent in shapely.

(I might actually even like "transform" a bit more, as it signals more that the geometry coordinates are only transformed, keeping the exact structure. While applying a function in general could return something else as geometries. For example, in pandas, there is a more generic "apply" (that can basically return anything) vs more specific "transform" (which is guaranteed to keep the same shaped output))

@coveralls
Copy link

coveralls commented May 22, 2022

Pull Request Test Coverage Report for Build 2524317425

  • 5 of 5 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 84.242%

Totals Coverage Status
Change from base Build 2523812064: 0.0%
Covered Lines: 2133
Relevant Lines: 2532

💛 - Coveralls

Copy link
Member

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

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

Yes to "transform" for this type of operation.

A new GEOS 3.11 feature is GEOSGeom_transformXY (and GEOSTransformXYCallback). This functionality has not yet made it into Shapely yet, although I can see that it would be useful optimization for "(N, 2)->(N, 2)" cases within shapely.coordinates.transform().

Copy link
Collaborator

@brendan-ward brendan-ward left a comment

Choose a reason for hiding this comment

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

+1 on the name change



def apply(geometry, transformation, include_z=False):
def transform(geometry, transformation, include_z=False):
Copy link
Collaborator

@caspervdw caspervdw Jun 6, 2022

Choose a reason for hiding this comment

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

The docstring should also be adjusted. And maybe also change the names all the way down to C?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the docstring

@jorisvandenbossche
Copy link
Member Author

And maybe also change the names all the way down to C?

The method currently only lives on the python side (the actual C funcs being called here are get_coordinates and set_coordinates, apply/transform being a python wrapper around those with calling the transform func in the middle)

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.

None yet

6 participants