-
Notifications
You must be signed in to change notification settings - Fork 211
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
inconsistent results in width_check when calling by keyword argument (python) #1793
Comments
Your The ignore angle should be in degrees not radian. From the docs:
So for proper comparison it should be Does this change the output of |
nice catch @sebastian-goeldi ! indeed it changes the results for the "never" case, but it does not change the fact that "sometimes" behaves inconsistently updated script: import klayout.db as kdb
import numpy as np
def always(value_dbu):
# min_projection is not set
return region.width_check(value_dbu, False, kdb.Metrics.Euclidian, 90)
def never(value_dbu):
# setting min_projection via a positional argument
return region.width_check(value_dbu, False, kdb.Metrics.Euclidian, 90, value_dbu)
def sometimes(value_dbu):
# setting min_projection via a named argument
return region.width_check(value_dbu, min_projection=value_dbu)
filename = r"troublesome_taper.oas"
l = kdb.Layout()
value_dbu = 1000
l.read(filename)
layer = l.layer(8, 0)
region = kdb.Region(l.begin_shapes(l.top_cell(), layer=layer))
for func in [always, never, sometimes]:
results = []
for i in range(30):
result = len(func(value_dbu))
results.append(str(result))
print(f"{func.__name__}: " + "".join(results)) Updated results: always: 111111111111111111111111111111
never: 111111111111111111111111111111
sometimes: 011000000000000000000000000000 |
hmm, time to upgrade to 0.29.4 (or linux :P); with 0.29.4 I get: unfixed ignore angle:
fixed to
Huh, this is worrisome. On linux with 0.29.2 I also get the correct output. @klayoutmatthias is the python kwargs binding different on windows than on linux/macos? |
i still get the inconsistent behavior on 0.29.4/windows 😞 interestingly, @sebastian-goeldi and I can both confirm that we get consistent results in the klayout GUI on Windows, but now oddly, we get the wrong result consistently (?). all three results should be the same now, but on windows GUI "sometimes" gives all zeros (only linux appears to show the correct behavior) 🤔 always: 11111111111111111111111111111111111111111111111111
never: 11111111111111111111111111111111111111111111111111
sometimes: 00000000000000000000000000000000000000000000000000 |
i can also confirm linux gives the correct results. it appears to be a windows issue |
I think I found the issue. The compiler does not warn if passing a return-by-value to "const &" .. :( It will be easy to fix. The issue happens only for keyword parameters with an enum- or object-type default value. In this case it was the Metrics type I think. Matthias |
Great! Thanks for the quick work getting to the bottom of it! A patch release would be appreciated once the fix is in |
Fixing issue #1793 (problem with default arguments in Python)
Hi @klayoutmatthias ,
I found a troublesome bug today when using a keyword argument to set the
min_projection
in awidth_check
for aRegion
object in python. I find that I get consistent results when calling using a positional argument but inconsistent results when using a keyword argument. Do you know why this might be?Please see the example script below:
Expected Output:
Actual Output:
I'm using the standalone klayout python package v0.29.2 on Windows 11.
Sample gds: troublesome_taper.zip
The text was updated successfully, but these errors were encountered: