phidl icon indicating copy to clipboard operation
phidl copied to clipboard

pg.boolean returns polygons where properties are the same object in memory

Open basnijholt opened this issue 3 years ago • 2 comments

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)

image 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?

basnijholt avatar Nov 04 '22 01:11 basnijholt

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

joamatab avatar Nov 07 '22 14:11 joamatab

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

amccaugh avatar Jan 05 '23 21:01 amccaugh