Skip to content

TST: update maximum_inscribed_circle tests for latest GEOS changes#2294

Merged
jorisvandenbossche merged 6 commits intoshapely:mainfrom
jorisvandenbossche:fix-error-msg-geos-main
May 19, 2025
Merged

TST: update maximum_inscribed_circle tests for latest GEOS changes#2294
jorisvandenbossche merged 6 commits intoshapely:mainfrom
jorisvandenbossche:fix-error-msg-geos-main

Conversation

@jorisvandenbossche
Copy link
Copy Markdown
Member

Some tests are failing on the GEOS main builds (eg https://github.com/shapely/shapely/actions/runs/14814815121/job/41593981112), related to some recent commits in GEOS (libgeos/geos@4ae3f05...6f4a739)

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

The test_rectangle_special_case failure seems to be a regression in behaviour on the GEOS side.

import matplotlib.pyplot as plt
import shapely
from shapely.plotting import plot_polygon, plot_line

polygon = shapely.Polygon(
    [
        (32.71997, -117.19310),
        (32.71997, -117.21065),
        (32.72408, -117.21065),
        (32.72408, -117.19310),
    ]
)
result = shapely.maximum_inscribed_circle(polygon)

fig, ax = plt.subplots()
plot_polygon(polygon, ax=ax)
plot_line(shapely.maximum_inscribed_circle(polygon), ax=ax, color="C1")

With GEOS 3.13.0:
test-geos-313

With GEOS 3.14.dev main:
test-geos-dev

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

Actually, the images are misleading because I was not using equal aspect ratio ..

Plotting this again, you can see that both results are strictly correct (they give the same size of circle). It's only that for the purpose of "polylabel", the more centered circle might give a better result.

Updated code
import matplotlib.pyplot as plt
import shapely
from shapely.plotting import plot_polygon, plot_line

polygon = shapely.Polygon(
    [
        (32.71997, -117.19310),
        (32.71997, -117.21065),
        (32.72408, -117.21065),
        (32.72408, -117.19310),
    ]
)
result = shapely.maximum_inscribed_circle(polygon)

fig, ax = plt.subplots()
plot_polygon(polygon, ax=ax)
plot_line(result, ax=ax, color="C1")
ax.set_aspect("equal")
plot_line(shapely.get_point(result, 0).buffer(result.length).boundary, ax=ax, color="C1", add_points=False)

With GEOS 3.13.0:

test-geos-313

With GEOS 3.14.dev main:

test-geos-dev

@mwtoews
Copy link
Copy Markdown
Member

mwtoews commented May 18, 2025

I agree with the upstream assessment that this is a "won't fix" since the input has a non-deterministic result. The input should be changed to yield a deterministic result.

$ pixi exec -s geos=3.10.1 geosop -f wkt -a "POLYGON ((100 0, 200 200, 300 200, 300 100, 100 0))" maxInscribedCircle 0.0001
LINESTRING (238.19656372070312 138.19656372070312, 182.91793823242188 165.83587646484375)
$ pixi exec -s geos=3.13.1 geosop -f wkt -a "POLYGON ((100 0, 200 200, 300 200, 300 100, 100 0))" maxInscribedCircle 0.0001
LINESTRING (238.19656372070312 138.19656372070312, 182.91793823242188 165.83587646484375)

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

The input should be changed to yield a deterministic result.

Then we can also just remove the test, since it was added specifically for this rectangle corner case (#644)

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

Going to merge this already to have green CI on main, but happy to follow-up with either updating or removing the test

@jorisvandenbossche jorisvandenbossche merged commit 19f8079 into shapely:main May 19, 2025
26 checks passed
@jorisvandenbossche jorisvandenbossche deleted the fix-error-msg-geos-main branch September 8, 2025 09:03
hillwithsmallfields pushed a commit to hillwithsmallfields/shapely that referenced this pull request Dec 9, 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.

2 participants