labscript-suite-temp-2 / runmanager

runmanager is a graphical user interface (GUI) used to aid the compilation of labscript experiment scripts into hardware instructions to be executed on the hardware. Experiment parameters can be adjusted in the GUI, and lists of parameters can be used to create sequences of experiments, and scan over complex parameter spaces.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Saving Length of Array to global throws KeyError #38

Closed philipstarkey closed 7 years ago

philipstarkey commented 7 years ago

Original report (archived issue) by David Meyer (Bitbucket: dihm, GitHub: dihm).


I have a global with a calculated numpy array. When I try to save the size of the array in another global (using darray.size or len(darray)) for further use I get the following traceback.

#!python
Traceback (most recent call last):
  File "C:\Anaconda2\envs\labscript\lib\threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "C:\Anaconda2\envs\labscript\lib\site-packages\zprocess\__init__.py", line 67, in f
    six.reraise(type, value, traceback)
  File "__main__.py", line 2273, in preparse_globals_loop
    self.preparse_globals()
  File "__main__.py", line 2250, in preparse_globals
    active_groups, evaled_globals, global_hierarchy, expansions)
  File "__main__.py", line 2975, in guess_expansion_modes
    expansion_types[dependency]['new_guess'] = str(global_name)
KeyError: u'numStates'

Doing some digging I've found that my length variable is being added as a dependency of the original array but it is not being populated in the expansions and expansion_types dictionaries, hence the key failure.

I suppose I could just calculate the required length external to runmanager where needed but it would be nice to have it as a global. Am I missing something obvious or is there something more fundamental going on?

philipstarkey commented 7 years ago

Original comment by Philip Starkey (Bitbucket: pstarkey, GitHub: philipstarkey).


Good find! There is a patch in pull request #5.

philipstarkey commented 7 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Fixes issue #38

Now check to make sure that global dependencies are only returned by find_dependencies when the result of the evaluated dependency is also an allowed expansion type (as determined by runmanager.guess_expansion_type).

→ \<\<cset 327d383fce7e4b224491a046ab9652ddb19255ac>>