nengo / nengo-gui

Nengo interactive visualizer
Other
95 stars 38 forks source link

"Module 'collections' has no attribute 'Iterable'" when running a simulation with a slider (Python 3.10) #1039

Closed astoeckel closed 2 years ago

astoeckel commented 2 years ago

Describe the bug

Nengo GUI crashes when starting a simulation that contains a slider.

To reproduce

  1. Install Python 3.10
  2. Add a slider to a node
  3. Click the "Play" button
Traceback (most recent call last):
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo_gui/page.py", line 491, in build
    self.sim = backend.Simulator(
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo/simulator.py", line 198, in __init__
    self.reset(seed=seed)
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo/simulator.py", line 335, in reset
    self._steps = [
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo/simulator.py", line 336, in <listcomp>
    op.make_step(self.signals, self.dt, self.rng) for op in self._step_order
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo/builder/processes.py", line 114, in make_step
    step_f = self.process.make_step(shape_in, shape_out, dt, rng, state)
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo_gui/components/slider.py", line 26, in make_step
    size_out = shape_out[0] if is_iterable(shape_out) else shape_out
  File "/home/andreas/.local/lib/python3.10/site-packages/nengo_gui/compat.py", line 35, in is_iterable
    return isinstance(obj, collections.Iterable)
AttributeError: module 'collections' has no attribute 'Iterable'

Expected behavior

Nengo GUI should not crash.

Versions

Additional context

Currently preparing a spring school lecture thingy where I teach people how to use Nengo (Apr 4 - 8). This should probably be fixed before then. I'll submit a PR.

tbekolay commented 2 years ago

See #1037, which already exists as a fix if you need it -- but I will say that NengoGUI does not currently claim to support versions of Python above 3.5.

astoeckel commented 2 years ago

Ah, didn't see that PR. I'd propose to close #1037 though; I will open my own PR. The collections.abc module existed since 3.3 and we do not support anything older than 3.4. So the additional try import except in #1037 is unnecessary.

Regarding the Python version, I'm half of aware of that; problem is that Nengo GUI is still the best tool to teach Nengo. Telling people to install a venv with an older Python version just complicates matters. So, if you don't mind, I will just fix the bugs I stumble across :-)

tbekolay commented 2 years ago

So, if you don't mind, I will just fix the bugs I stumble across :-)

Sure, sounds good. I have an issue I wanted to fix as well so I'll fix at the same time as review/merging any changes you come across :+1:

astoeckel commented 2 years ago

I opened the PR #1040. Let me know if I should review any of your changes.