labscript-suite / runmanager

๐—ฟ๐˜‚๐—ป๐—บ๐—ฎ๐—ป๐—ฎ๐—ด๐—ฒ๐—ฟ is an intuitive graphical interface for controlling ๐˜ญ๐˜ข๐˜ฃ๐˜ด๐˜ค๐˜ณ๐˜ช๐˜ฑ๐˜ต ๐˜ด๐˜ถ๐˜ช๐˜ต๐˜ฆ experiments. Includes multi-dimensional parameter scans and a remote programming interface for automation.
http://labscriptsuite.org
Other
3 stars 45 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>>