jonescompneurolab / hnn-core

Simulation and optimization of neural circuits for MEG/EEG source estimates
https://jonescompneurolab.github.io/hnn-core/
BSD 3-Clause "New" or "Revised" License
51 stars 50 forks source link

GUI: Creating figures with no data throws multiple exceptions #742

Open kmilo9999 opened 3 months ago

kmilo9999 commented 3 months ago
          The first bug is located in the `link_attribute.unlink()` method, which calls the `traitlets `package, a dependency of `ipywidgets`. These are the steps to reproduce it:
  1. Make an empty figure with no sim or loaded data in the app.
  2. Load or simulate data.

This is the traceback:

'Traceback (most recent call last):
 File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 126, in wrapper
 link_attribute.unlink()
 File "/mnt/c/Projects/Github/hnn-core-ccv/venv310/lib/python3.10/site-packages/traitlets/traitlets.py", line 344, in unlink
 self.source[0].unobserve(self._update_target, names=self.source[1])
 File "/mnt/c/Projects/Github/hnn-core-ccv/venv310/lib/python3.10/site-packages/traitlets/traitlets.py", line 1698, in unobserve
 self._remove_notifiers(handler, name, type)
 File "/mnt/c/Projects/Github/hnn-core-ccv/venv310/lib/python3.10/site-packages/traitlets/traitlets.py", line 1592, in _remove_notifiers
 self._trait_notifiers[name][type].remove(handler)\nValueError: list.remove(x): x not in list'

The second bug is when you go to the visualization tab with no loaded data, and click the button 'Make figure'. This is the traceback:


 'Traceback (most recent call last):  
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 129, in wrapper    
  result = f(self, *args, **kwargs)
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 811, in add_figure
  _add_figure(None,
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 685, in _add_figure
  _add_axes_controls(widgets, data, fig=fig, axd=axd)
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 627, in _add_axes_controls
  children = [
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 628, in <listcomp>
  _get_ax_control(widgets, data, fig_idx=fig_idx, fig=fig, ax=ax)
  File "/mnt/c/Projects/Github/hnn-core-ccv/hnn_core/gui/_viz_manager.py", line 432, in _get_ax_control
  sim_name_default = simulation_names[-1]\nIndexError: tuple index out of range'

_Originally posted by @kmilo9999 in https://github.com/jonescompneurolab/hnn-core/pull/730#discussion_r1543324666_