Internal error in Shapes.insert() for linux

edited March 2021 in Python scripting

Hello, I encounter this error when I try to run my code in linux. It perfectly works in windows.
For debugging I have put some print statements. I will put the output of the print statements as comment.

            layout_dbu = 10000
            output_layout = pya.Layout()
            output_layout.dbu = 1 / layout_dbu

            subcell = output_layout.cell('mycell')

            print(polygon)  ###  (-0.15,-4;-0.15,4;0.15,4;0.15,-4)
            print(type(polygon))   ### <class 'pya.DPolygon'>
            print(the_layer)  ####  0 
            print(type(the_layer)) ##  <type 'long'>
            subcell.shapes(the_layer).insert(polygon)

It is giving me the following error:

ERROR: /var/lib/jenkins/workspace/multibranch-centos7_staging/src/db/db/dbTrans.h,1619,mag > 0.0
ERROR: Internal error: /var/lib/jenkins/workspace/multibranch-centos7_staging/src/db/db/dbTrans.h:1619 mag > 0.0 was not true in Shapes.insert

Another interesting thing I have noticed is that, this error goes away when I comment out this part:
output_layout.dbu = 1/layout_dbu

The source code is very long that's why I have just put the relevant part. Please let me know if this information is not enough.

Thank you! :smile:

Comments

  • edited March 2021

    Hi @Ege_Bey I quickly checked on my end whether I can reproduce the error. I cannot. For reference I used the following code

    import pya
    
    layout = pya.CellView.active().layout()
    cell = layout.top_cell()
    
    layout_dbu = 10000
    layout.dbu=1/layout_dbu
    
    layer = layout.layer(1,0) ### Create Layer on index=1, datatype =0
    
    polygon = pya.DPolygon([pya.DPoint(p[0],p[1]) for p in [[-.15,-5],[-.15,5],[.15,5],[.15,-4]]])
    
    print(f"{polygon.__str__()=}") ### polygon.__str__()='(-0.15,-5;-0.15,5;0.15,5;0.15,-4)'
    print(f"{type(polygon)=}")   ### <class 'pya.DPolygon'>
    print(f"{layer=}")  ####  0 
    print(f"{type(layer)=}") ##  <class 'int'>
    
    cell.shapes(layer).insert(polygon)
    

    Are you by any chance using KLayout with a python 2.7 environment? In python 2.7 1/10000 == 0 since it is evaluated as an integer division. And a database unit of 0 won't work :) . In that case you should do layout.dbu = 1./10000. If I manually add layout.dbu = 0, I will get the exact error you get :wink:

    Btw the print statements won't work with python < 3.9 (maybe it works with 3.8, can't remember when they added these nice f string prints :smiley: ).

    Hope this helps

    Best,
    Sebastian

    P.S. I would strongly recommend updating to a KLayout version which uses python3 (preferably >= 3.7) as python 2.7 is now not maintained any more at all

  • Hi Sebastian!

    Thanks a lot! setting layout.dbu = 1./10000 solved my problem :wink:
    It is amazing what single "." can do :smiley: That "." could cause me hours of struggle!
    Thanks again :smile: !

  • @sebastian Thanks a lot. That's a very valuable comment indeed!

    Matthias

Sign In or Register to comment.