-
-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
It might be nice to allow an optional arg to Cell.bounding_box that would eliminate me needing to round to 1nm precision (just found an issue where some number had 11 zeroes and then a 1 after the two significant decimals (120.96 was coming as 120.96000000000001) with code like:
import gdstk
def bounding_box_with_rounding(polygon, rounding=None):
original_bb = polygon.bounding_box()
if rounding is not None:
return tuple(tuple(round(coord, rounding) for coord in point) for point in original_bb)
return original_bb
# Example usage
cell_boundary = gdstk.Polygon([(0.123456, 0.654321), (1.987654, 2.345678)])
cb_bb = bounding_box_with_rounding(cell_boundary, rounding=4)
print(cb_bb) # Output: ((0.1235, 0.6543), (1.9877, 2.3457))
Metadata
Metadata
Assignees
Labels
No labels