-
Notifications
You must be signed in to change notification settings - Fork 211
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
Docs inconsistency about shape.each_point() iterator #547
Comments
Hi, well, the error message could be somewhat more comprehensible ... but doc and code are consistent. The message basically says "I'm expecting a path". A simple polygon isn't a path. The explanation is: "each_point" only applies to paths. Paths are not polygons, but "wires": a path is a sequence of points and a width. The path connects the points by straight lines with the given width. A simple polygon is a closed loop of points (the vertexes). This is the "hull". A general polygon in addition may have zero to many holes. Holes are also closed loops, but with the opposite orientation of the hull (counterclockwise, while the hull is clockwise). An overview over the shape types is given here: https://www.klayout.de/doc/programming/geometry_api.html So for paths: each_point. For simple polygons: each_point_hull. For general polygons: each_point_hull + each_point_hole(n = 0 .. holes-1). Here is a big fat warning regarding your code: "if s.is_simple_polygon:" is always true! Because "is_simple_polygon" gives you the method object, not the result of the method call. You have to use:
I hate Python for this! Matthias |
I'll take this ticket as "give me better error messages" ... |
Hi Matthias, thanks for looking into this! Indeed, I should have used brackets in the example. (In my actual code I do :) ). My remark about the docs was that they say Best regards, |
I see ... that's acutally easy to fix: there is no such method. "each_point" is only there for paths. It would not make much sense to iterate points over hulls and holes if there is no indication which loop the point belongs to. Better use "each_point_hull" and "each_point_hole". |
Thanks a lot! |
By the way, for simple polygons there is |
Hi Matthias,
I have found some disagreement in the docs regarding
Shape.each_point()
iterator.This page https://www.klayout.de/doc/programming/database_api.html#h2-1056 says:
The docs for the
Shape.each_shape()
method on https://www.klayout.de/doc/code/class_Shape.html#method97 say:When I try to run the following code on pypi klayout package (v.0.26.4), the statement from the first page is not correct, and exception is raised:
The error raised is the following:
RuntimeError: Internal error: src\db\db\dbShape.cc:159 false was not true in Shape.each_point
. The error is an assert statement, so I guess the execution was not supposed to reach there at all...The text was updated successfully, but these errors were encountered: