Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix composable loop reinit bug #127

Merged
merged 3 commits into from
Jun 22, 2023
Merged

Conversation

MaxSchambach
Copy link
Contributor

@MaxSchambach MaxSchambach commented Jun 20, 2023

Description

Fixes a tiny but significant bug in loop method of Composable class.
Running an infinite loop previously resulted in yielding only the very first item of the IterableSource due to a reinitialization of the iterator caused by a wrong indentation level.

The fix is straightforward by correcting the indentation level of the iterator reinitialization.

A test is added to testcase the infinite-loop setting which was previously untested.

See the test or this simple snippet to showcase the bug:

from squirrel.iterstream.source import IterableSource

source = IterableSource(range(3)).loop()

for i, x in enumerate(source):
    print(x)
    if i == 9:
        break
# previously yielded [0, 0, ..., 0], should yield [0, 1, 2, ..., 1, 2]

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring including code style reformatting
  • Other (please describe):

Checklist:

  • I have read the contributing guideline doc (external contributors only)
  • Lint and unit tests pass locally with my changes
  • I have kept the PR small so that it can be easily reviewed
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • All dependency changes have been reflected in the pip requirement files.

AlirezaSohofi
AlirezaSohofi previously approved these changes Jun 21, 2023
Copy link
Contributor

@AlirezaSohofi AlirezaSohofi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks a lot for the fix 👍

@AlirezaSohofi
Copy link
Contributor

@MaxSchambach can you please increment the version?

@MaxSchambach
Copy link
Contributor Author

Thanks! Version is bumped.

Copy link
Contributor

@AlirezaSohofi AlirezaSohofi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MaxSchambach MaxSchambach merged commit 6201509 into main Jun 22, 2023
@MaxSchambach MaxSchambach deleted the max-fix-composable-loop-reinit-bug branch June 22, 2023 14:04
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants