-
Notifications
You must be signed in to change notification settings - Fork 111
Rename method to clarify functionality in geometry processing #509
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 method to clarify functionality in geometry processing #509
Conversation
|
Hi @EdwardAstill, thanks for the PR. The test suite is failing because As a result these lines will need to be updated to suit. Would you like me to fix this or do you want to give it a shot? |
|
Hi Robbie, |
|
Hi @EdwardAstill I believe I've fixed the issue however am unable to push to your branch. Did you uncheck allowing maintainers to edit your branch? See here for more info. |
|
The allow edits by maintainers box is checked. It shouldn't have been unchecked though. |
|
Ok strange! For some reason when I try to push it says I'm unauthenticated, haven't had this issue before! I'll make comments on this PR for the changes I've made to make this work if you want to make the commits and keep the contributor credit :) Otherwise I can make a new PR, up to you 👍 |
| new_polygons = c2s.utils.find_holes(polygons) | ||
| new_polygons = c2s.utils.filter_polygons(polygons) | ||
|
|
||
| if isinstance(new_polygons, MultiPolygon): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace lines 2516 -> 2522 with:
# ensure list length > 0
if len(new_polygons) == 0:
msg = f"No shapely.Polygon objects found in file: {dxf_filepath}"
raise RuntimeError(msg)
# ensure only Polygons are generated
for poly in new_polygons:
if not isinstance(poly, Polygon): # pyright: ignore [reportUnnecessaryIsInstance]
msg = f"Not all objects found in file: {dxf_filepath} are Polygons"
raise RuntimeError(msg)
if len(new_polygons) == 1:
return Geometry(new_polygons[0])
else:
return CompoundGeometry(MultiPolygon(new_polygons))|
Further to get the type checking to work, you will need to change the following files:
from .dxf import DxfImporter
from .utils import filter_polygons, find_holes
from shapely.geometry import Polygon
def find_holes(polygons: list[Polygon]) -> Polygon: ...
def filter_polygons(
polygons: list[Polygon],
filter_flag: int = ...,
) -> list[Polygon]: ... |
|
I'm happy for you to make a new PR seeing as I didn't really change anything. Hopefully I'll make a more meaningful contribution in the future. |
Replaced `find_holes` with `filter_polygons` to improve clarity of intent and better reflect the method's purpose. This change enhances code readability and semantic accuracy in the polygon filtering process.
Pull Request Check List
Resolves: #issue-number-here
uv run pre-commit run --all-filesanduv run pyrightto ensure code quality.Changed method to avoid deprecation warning