Skip to content

BUG: fix base geometry "project" to return Python float#2093

Merged
jorisvandenbossche merged 1 commit intoshapely:mainfrom
mwtoews:numpy2-linref-float
Jul 25, 2024
Merged

BUG: fix base geometry "project" to return Python float#2093
jorisvandenbossche merged 1 commit intoshapely:mainfrom
mwtoews:numpy2-linref-float

Conversation

@mwtoews
Copy link
Copy Markdown
Member

@mwtoews mwtoews commented Jul 20, 2024

Similar to #2074, this PR restores line.project(point) to return a Python float, and not a NumPy float64 scalar. It similarly changes line_locate_point as well.

This is more obvious with NumPy 2.0:

>>> import shapely
>>> line = shapely.from_wkt("LINESTRING (0 0, 1 0)")
>>> point = shapely.from_wkt("POINT(0 1)")
>>> line.project(point)
np.float64(0.0)
>>> line.line_locate_point(point)
np.float64(0.0)

this PR changes the functions to return Python float(0.0) instead (or 0.0).

Tests are improved to check other scalar results, and test project and interpolate function aliases too.

@mwtoews mwtoews force-pushed the numpy2-linref-float branch from 3ee0880 to 36e3faa Compare July 20, 2024 12:37
@mwtoews mwtoews changed the title BUG: fix base geometry linear ref functions to return Python floats BUG: fix base geometry "project" to return Python float Jul 20, 2024
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 20, 2024

Pull Request Test Coverage Report for Build 10020253477

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 88.158%

Totals Coverage Status
Change from base Build 9918991219: 0.3%
Covered Lines: 2628
Relevant Lines: 2981

💛 - Coveralls

Copy link
Copy Markdown
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@jorisvandenbossche jorisvandenbossche merged commit 1b15cc7 into shapely:main Jul 25, 2024
@mwtoews mwtoews deleted the numpy2-linref-float branch July 25, 2024 09:21
@theroggy theroggy added this to the 2.1 milestone Feb 20, 2025
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.

4 participants