nengo / nengo-gui

Nengo interactive visualizer
Other
95 stars 38 forks source link

Signal dict KeyError when displaying voltage plots with a model containing more than one ensemble #1034

Open xchoo opened 3 years ago

xchoo commented 3 years ago

Describe the bug

If you try to display the voltage plot with a network containing more than one ensemble, the following error is produced intermittently. Sometimes spamming the play button fixes it.

Traceback (most recent call last):
  File "/home/xchoo/miniconda3/envs/test2/lib/python3.8/site-packages/nengo/builder/signal.py", line 261, in __getitem__
    return dict.__getitem__(self, key)
KeyError: Signal(<Neurons of <Ensemble (unlabeled) at 0x7f44d417a640>>.voltage[(slice(None, 5, None),)], shape=(5,))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xchoo/miniconda3/envs/test2/lib/python3.8/site-packages/nengo_gui/page.py", line 526, in runner
    self.sim.step()
  File "/home/xchoo/miniconda3/envs/test2/lib/python3.8/site-packages/nengo/simulator.py", line 353, in step
    self._probe()
  File "/home/xchoo/miniconda3/envs/test2/lib/python3.8/site-packages/nengo/simulator.py", line 239, in _probe
    tmp = self.signals[self.model.sig[probe]['in']].copy()
  File "/home/xchoo/miniconda3/envs/test2/lib/python3.8/site-packages/nengo/builder/signal.py", line 265, in __getitem__
    base = dict.__getitem__(self, key.base)
KeyError: Signal(<Neurons of <Ensemble (unlabeled) at 0x7f44d417a640>>.voltage, shape=(100,))

To reproduce

Steps to reproduce the behavior:

  1. Load the "communication_channel" basic example
  2. Pull up the voltage plot for any of the ensembles
  3. Push the play button
  4. Error is produced

Expected behavior

An error should not be produced.

Screenshots

If applicable, add screenshots to help explain your problem.

Versions

Additional context

It seems like it might be a threading issue, where the GUI is trying to get a handle on the signal before it is created? Or maybe an ordered dict issue? One oddity is that if you pull up another plot with the voltage plot, the probability of the error occurring goes down.

FilipDepta commented 3 years ago

Switching to another backend (tested with Nengo OCL) results in not producing an error.

Versions