Shapely like API for exterior#31
Merged
mindflayer merged 7 commits intomainfrom Dec 10, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the ToGo library to provide a more Shapely-compatible API by converting several methods to properties. Specifically, it changes Poly.exterior from a method to a property, and converts several Ring class methods (area, perimeter/length, is_convex, is_clockwise) to properties. The PR also adds a new Poly.length property for perimeter calculation.
- Converted
Poly.exterior()method toexteriorproperty for Shapely compatibility - Converted
Ringmethods (area,perimeter,is_convex,is_clockwise) to properties, withperimeterrenamed tolengthfor Shapely compatibility - Added new
Poly.lengthproperty that returns the perimeter of the polygon's exterior ring
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| togo.pyx | Converted Poly.exterior, Ring.area, Ring.perimeter (renamed to length), Ring.is_convex, and Ring.is_clockwise from methods to properties; added new Poly.length property; updated __geo_interface__ to use property access; attempted to fix error message string formatting (but has bug) |
| tests/test_shapely_api.py | Updated test calls to use exterior as property instead of method |
| tests/test_ring.py | Updated test calls to use Ring properties (area, length, is_convex, is_clockwise) instead of methods |
| tests/test_poly.py | Updated test calls to use exterior as property and Ring properties instead of methods |
| tests/test_geometry.py | Updated test calls to use exterior as property instead of method |
| examples/shapely_api_demo.py | Updated example to use exterior as property instead of method |
| benchmarks/bench_shapely_vs_togo.py | Updated benchmark to use exterior.length property instead of exterior().perimeter() method |
| SHAPELY_API.md | Updated documentation to show exterior as property instead of method, but comment incorrectly indicates it's a method |
| README.md | Updated some examples to use area and length properties, but is_convex() and is_clockwise() still shown as method calls instead of properties |
| QUICK_REFERENCE.md | Updated documentation to show exterior as property instead of method |
| setup.py | Added compiler flag -Wno-int-in-bool-context to suppress Cython-generated code warnings |
Comments suppressed due to low confidence (1)
README.md:182
- The
is_convexandis_clockwiseproperties should be accessed without parentheses (as properties, not method calls) to be consistent with the changes made to theRingclass intogo.pyxwhere these were converted from methods to properties with the@propertydecorator.
print(f"Is convex: {ring.is_convex()}")
print(f"Is clockwise: {ring.is_clockwise()}")
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mindflayer
commented
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.