phidl
phidl copied to clipboard
pg.boolean returns polygons where properties are the same object in memory
See:
import phidl
a = phidl.geometry.bbox(bbox=[(0, 0), (1, 2)])
b = phidl.geometry.bbox(bbox=[(0, 0.5), (1, 1.5)])
d = phidl.geometry.boolean(a, b, operation="not")
phidl.quickplot([a, b])
set(id(p.properties) for p in d.polygons)
and prints:
{6076552704}
which means that
d.polygons[0].properties["a"] = 1
print(d.polygons[1].properties)
prints {'a': 1}.
@joamatab, maybe also happens in gdsfactory?
yes Bas, and at least in gdsfactory you cannot save the GDS after setting the properties of the polygons
https://github.com/gdsfactory/gdsfactory/issues/821
I'm not really familiar with properties it seems -- what are they generally used for? Some kind of dictionary I see, but are they present in the GDSII spec, or are they custom to gdspy? What is the expected behavior here? I'm a little baffled that any memory is shared between the output of pg.boolean and its inputs, but I can look into it if that would be useful