You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Grml ... I knew too much smartness would finally create some trouble ... :(
Basically, the whole scheme why this is works is the inference logic KLayout uses: if an argument expects an object, but is passed an array, KLayout tries to call the object constructor from the arguments of the array. This also works for array elements.
This is way (0,0) can create a DPoint in the DPolygon([DPoint, DPoint, ... ]) constructor. In the same fashion a four-element array can be matched to the arguments of DBox in the DPolygon(DBox) constructor. This is what happens here and creates that ambiguity.
I can fix this by giving precedence of array matching array (I think).
The best workaround is to use "assign_hull" which does not have a Box overload:
Activity
sebastian-goeldi commentedon Mar 10, 2024
This works, but it seems the .pyi didn't pick up the new function overload.
sebastian-goeldi commentedon Mar 10, 2024
The issue seems to be if the list has exactly 4 points, then the creation fails
@klayoutmatthias could it be that klayout tries to cast to a Box first here?
[-]create Polygons from lists[/-][+]errors when adding polygons with 4 points [/+]klayoutmatthias commentedon Mar 10, 2024
Grml ... I knew too much smartness would finally create some trouble ... :(
Basically, the whole scheme why this is works is the inference logic KLayout uses: if an argument expects an object, but is passed an array, KLayout tries to call the object constructor from the arguments of the array. This also works for array elements.
This is way
(0,0)can create aDPointin theDPolygon([DPoint, DPoint, ... ])constructor. In the same fashion a four-element array can be matched to the arguments ofDBoxin theDPolygon(DBox)constructor. This is what happens here and creates that ambiguity.I can fix this by giving precedence of array matching array (I think).
The best workaround is to use "assign_hull" which does not have a
Boxoverload:Matthias
joamatab commentedon Mar 10, 2024
awesome! that worked, thank you Matthias!
feel free to close this
klayoutmatthias commentedon Mar 10, 2024
Very good, thanks for the feedback.
I'll keep that ticket open to remind me of this stupid ambiguity. I shall be less permissive on the inference paths.
Matthias
Fixing issue #1651 (errors when adding polygons with 4 points) - need…
Merge pull request #1660 from KLayout/issue-1651