Describe the bug
Looping over an empty Party results in an infinite loop of None results
To Reproduce
from eqcorrscan import Party
party = Party()
for f in party:
print(f)
Result:
None
None
...
for ever...
This happens because the Party.__getitem__ method returns None if the Party is empty.
Expected behavior
To maintain the .__getitem__ behavior (which isn't correct, but is in the code in use now...) we can just define an __iter__ method and __next__ method properly as such:
Describe the bug Looping over an empty
Party
results in an infinite loop ofNone
resultsTo Reproduce
Result:
for ever...
This happens because the
Party.__getitem__
method returnsNone
if theParty
is empty.Expected behavior To maintain the
.__getitem__
behavior (which isn't correct, but is in the code in use now...) we can just define an__iter__
method and__next__
method properly as such:Desktop (please complete the following information):
Additional context Bugger, what a silly mistake.
I should check the other objects to make sure iterating over them isn't similarly broken!