Skip to content

Refactor affine_transform: use general function apply on coordinates#1019

Merged
jorisvandenbossche merged 2 commits intoshapely:shapely-2.0from
jorisvandenbossche:refactor-affine-transform
Nov 11, 2020
Merged

Refactor affine_transform: use general function apply on coordinates#1019
jorisvandenbossche merged 2 commits intoshapely:shapely-2.0from
jorisvandenbossche:refactor-affine-transform

Conversation

@jorisvandenbossche
Copy link
Copy Markdown
Member

In pygeos, we have a general apply method to apply a function on the coordinates and recreate geometries from those transformed geometries (we probably need to rename it to transform, but that's another issue).

This speeds up the affine transforms again a bit (which saw a slowdown in #983). The specific example of #983 (comment) is now again at the same speed as with released Shapely:

In [1]: from shapely.geometry import Polygon

In [2]: poly = Polygon([(0,1), (1, 2), (2, 1), (1, 0), (0, 1)])

In [3]: %timeit poly.minimum_rotated_rectangle
275 µs ± 6.98 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

Now, for single geometries, I don't think we need to expect speed-ups, certainly not compared to the cython code (that I removed here).

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

Note that the tests are still failing because pygeos.apply doesn't support 3D coords, yet (working on that)

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.7%) to 76.03% when pulling 8199b6d on jorisvandenbossche:refactor-affine-transform into 4f28db9 on Toblerity:shapely-2.0.

Copy link
Copy Markdown
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.

Great to see similar performance to the "speedups" implementation and to preserve 3D capabilities, thanks!

@jorisvandenbossche jorisvandenbossche merged commit c6154f3 into shapely:shapely-2.0 Nov 11, 2020
@jorisvandenbossche jorisvandenbossche deleted the refactor-affine-transform branch November 11, 2020 11:47
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request Nov 27, 2020
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request Apr 5, 2021
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request Apr 5, 2021
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request May 27, 2021
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request May 27, 2021
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request Aug 20, 2021
jorisvandenbossche added a commit to jorisvandenbossche/shapely that referenced this pull request Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants