Skip to content

inconsistent results in width_check when calling by keyword argument (python) #1793

@tvt173

Description

@tvt173

Hi @klayoutmatthias ,

I found a troublesome bug today when using a keyword argument to set the min_projection in a width_check for a Region 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:

import klayout.db as kdb
import numpy as np

def always(value_dbu):
    # min_projection is not set
    return region.width_check(value_dbu)

def never(value_dbu):
    # setting min_projection via a positional argument
    return region.width_check(value_dbu, False, kdb.Metrics.Euclidian, np.deg2rad(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))

Expected Output:

always: 111111111111111111111111111111
never: 000000000000000000000000000000
sometimes: 000000000000000000000000000000

Actual Output:

always: 111111111111111111111111111111
never: 000000000000000000000000000000
sometimes: 011000100001001100000100000000

I'm using the standalone klayout python package v0.29.2 on Windows 11.

Sample gds: troublesome_taper.zip

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions