Skip to content
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

Region.sized after .smooth returns empty region on 0.28.4 #1275

Closed
caspar-iqm opened this issue Feb 4, 2023 · 4 comments
Closed

Region.sized after .smooth returns empty region on 0.28.4 #1275

caspar-iqm opened this issue Feb 4, 2023 · 4 comments
Assignees
Labels
Milestone

Comments

@caspar-iqm
Copy link

Here is a pretty obscure bug report!

It looks like on 0.28.4, Region.smooth does something that prevents further size or sized operations on the region to work as expected.

Try the following macro:

from pya import Point, Polygon, Region

polygon = Polygon([Point(-21983, -43808), Point(-37841, 16636), Point(-20484, 35228), Point(30428, 41627), Point(38312, 28960), Point(-7811, -37922)])

# NOT WORKING: Region.sized or Region.size after Region.smooth results in empty region
region = Region(polygon)
region.smooth(100)
print("Original smooth:", str(region))  # 

region_sized = region.sized(100)
print("Sized after smooth:", str(region_sized))

# WORKING: Region.sized or Region.size after Region.smoothed works as expected
region = Region(polygon)
region = region.smoothed(100)
print("Original smoothed:", str(region))  # 

region_sized = region.sized(100)
print("Sized after smoothed:", str(region_sized))

On 0.28.4, the output is

Original smooth: (-21983,-43808;-37841,16636;-20484,35228;30428,41627;38312,28960;-7811,-37922)
Sized after smooth: 
Original smoothed: (-21983,-43808;-37841,16636;-20484,35228;30428,41627;38312,28960;-7811,-37922)
Sized after smoothed: (-22037,-43939;-22054,-43930;-37952,16664;-20532,35323;30479,41734;38432,28957;-7745,-38003)

On 0.28.3 it works correctly ("Sized after smooth" is the same as "Sized after smoothed").

It seems related to in-place editing in smooth having some side-effect. Re-creating the Region object as follows also fixes the issue:

region = Region(polygon)
region.smooth(100)
region = Region(list(region.each()))
print("Original smooth:", str(region))  # 

region_sized = region.sized(100)
print("Sized after smooth:", str(region_sized))
@sebastian-goeldi
Copy link
Contributor

I believe this should never have worked. If you look at the docs smooth returns void (and always did according to the docs iirc). https://klayout.de/doc-qt5/code/class_Region.html#method198 . Same with round_corners.

I have wondered in the past about this. @klayoutmatthias would it be possible to standardize the return types (my preference would be that they return this, but I can also live with void), or is there a reason for different behavior?

@klayoutmatthias
Copy link
Collaborator

I am terribly sorry, this is a bug I have introduced in 0.28.4 during the enabling of user properties.

I'm in release mood anyway, so I'll quickly generate a 0.28.5 release with that bug fixed.

@klayoutmatthias klayoutmatthias self-assigned this Feb 4, 2023
@klayoutmatthias klayoutmatthias added this to the 0.28.5 milestone Feb 4, 2023
klayoutmatthias added a commit that referenced this issue Feb 4, 2023
Fixed issue #1275 (size after smooth does not work)
@caspar-iqm
Copy link
Author

Thank you for the quick fix, amazing work!

@klayoutmatthias
Copy link
Collaborator

Is fixed with 0.28.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants