hohlraum / gdsCAD

A simple but powerful Python package for creating photolithography masks in the GDSII format.
GNU General Public License v3.0
88 stars 52 forks source link

global name '_incomplete' is not defined #34

Closed glemi closed 7 years ago

glemi commented 9 years ago

in gdsCAD version 0.4.5, in core.py I get an error when using GdsImport on a particular .gds file.

NameError: global name '_incomplete' is not defined

here is the code where the error occurrs (around line 2174):

def _create_reference(**kwargs):
    kwargs['origin'] = kwargs.pop('xy')
    ref = CellReference(**kwargs)
    if not isinstance(ref.ref_cell, Cell):
        _incomplete.append(ref)
    return ref

_incomplete is initialized in GdsImport as an empty list [] but it's outside the scope of where _create_reference is defined. It is also used in _create_array, and would probably generate the same error when executed.

I have tried out-commenting the if block in _create_reference but then I get errors later on because ref.ref_cell is a string instead of a Cell object.

edit: I fixed this to some extent by declaring _incomplete as a global variable in the core.py module. However now when GdsImprt tries to resolve the references, it looks up the string value of ref.ref_cell in cell_dict, which again is not defined (around line 2041).

mabl commented 9 years ago

Hi @glemi,

try out my branch here: https://github.com/mabl/gdsCAD/tree/fix_gds_import

This should work also for nestes Cell references. I've but up a pull request here, but looks like @hohlraum is busy.

Tokin256 commented 8 years ago

Hi @mabl! I suffered from the same problem. Your branch seems to be working! Thanks!

hohlraum commented 7 years ago

Fixed by PR #33.