nest-simulator icon indicating copy to clipboard operation
nest-simulator copied to clipboard

Iterating on an empty `SynapseCollection` raises `TypeError: 'NoneType' object is not iterable`

Open CircuitCoder opened this issue 2 years ago • 1 comments

Describe the bug Iterating on an empty SynapseCollection raises TypeError: 'NoneType' object is not iterable.

It seems that this is caused by:

  1. When SynapseCollection is empty, its _datum field is None
  2. Constructor of SynapseCollectionIterator doesn't check for this case.

To Reproduce Steps to reproduce the behavior:

>>> s = nest.SynapseCollection(None)
>>> for row in s:
...     pass
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/nest/lib/python3.10/site-packages/nest/lib/hl_api_types.py", line 608, in __iter__
    return SynapseCollectionIterator(self)
  File "/opt/nest/lib/python3.10/site-packages/nest/lib/hl_api_types.py", line 567, in __init__
    self._iter = iter(synapse_collection._datum)
TypeError: 'NoneType' object is not iterable

Expected behavior SynapseCollectionIterator creates an empty iterator when the collection is empty.

Desktop/Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • Shell: bash
  • Python-Version: 3.10.12
  • NEST-Version: 3.5.0
  • Installation: docker

CircuitCoder avatar Sep 25 '23 03:09 CircuitCoder

Issue automatically marked stale!

github-actions[bot] avatar Nov 25 '23 08:11 github-actions[bot]