klayout icon indicating copy to clipboard operation
klayout copied to clipboard

pya.Library().library_by_name() for unspecified technology not functioning

Open lukasc-ubc opened this issue 3 years ago • 1 comments

Based on the documentation, https://www.klayout.de/doc/code/class_Library.html#method21

I am able to get the string name for the library: pya.Library().library_names()[0]

But not able to ask for a library by name; the following doesn't work: pya.Library().library_by_name(pya.Library().library_names()[0])

pya.Library().library_by_name(pya.Library().library_names()[1])

I get a blank.

It seems intermittent:

> [pya.Library().library_by_name(l) for l in pya.Library().library_names()]

[None, None, None, None, None, None, None, None, None, <pya.Library object at 0x14b4c6740>, None, None, None, None, None, None, None, None, None, None, <__main__.MyLib object at 0x14b52edc0>, <__main__.PCellLib object at 0x14b4f4d40>, <__main__.xxx object at 0x14b69f0c0>, <pya.Library object at 0x14b526f40>, <__main__.SiEPIC_General object at 0x14b644040>, None, None, None, None, <SiEPICfab_Grouse_Base_Library.SiEPICfab_Grouse_Base_Dev object at 0x14b9cdec0>, None, None, None, None, None, None, None, None]

Then I try with the technology as an argument, and it works correctly:

> [pya.Library().library_by_name(l,'SiEPICfab_Shuksan_PDK') for l in pya.Library().library_names()]

[None, None, None, None, None, None, None, None, None, <pya.Library object at 0x14b4c6740>, None, None, None, None, None, None, None, None, None, <Designs.design_lukasc.Library_lukasc object at 0x14cd540c0>, <__main__.MyLib object at 0x14b52edc0>, <__main__.PCellLib object at 0x14b4f4d40>, <__main__.xxx object at 0x14b69f0c0>, <pya.Library object at 0x14b526f40>, <__main__.SiEPIC_General object at 0x14b644040>, None, None, None, None, <SiEPICfab_Grouse_Base_Library.SiEPICfab_Grouse_Base_Dev object at 0x14b9cdec0>, None, None, None, None, None, None, <__main__.SiEPICfab_Shuksan_Library object at 0x14bb00940>, None]

lukasc-ubc avatar Feb 09 '22 07:02 lukasc-ubc

I think the explanation is the following: if you have multiple libraries with the same name, "library_by_name" will return "None" to indicate the name is ambiguous.

If you add a technology, KLayout will select the matching library and the technology acts as a disambiguator. The return value will be valid then.

Does that explain the effect?

Matthias

klayoutmatthias avatar Feb 11 '22 15:02 klayoutmatthias