Repository navigation
Fix zip_with_next raising TypeError when chained after lazy transforms - #219
Open
TrueFurina wants to merge 2 commits into
Open
TrueFurina wants to merge 2 commits into
TrueFurina wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sequence.zip_with_nextraisesTypeError: 'map'/'filter' object is not subscriptablewhen it is chained after a lazy (non-PRE_COMPUTE) transform such asmap,filter,select, etc.Root cause
The transform is defined as:
In the serial execution engine, a transform without
PRE_COMPUTEreceives the raw upstream iterator (not a list). Sincezip_with_nextsubscripts its input (sequence[1:]), feeding it an iterator raisesTypeError.This is the same class of bug as #136 ("Reverse fails on sequences"), which was fixed for
reverseby addingPRE_COMPUTE. The sibling transformsinit,inits,tails, andslidingalready usePRE_COMPUTEfor exactly this reason —zip_with_nextwas simply missed when it was added in #217.Fix
Mark
zip_with_next_twithExecutionStrategies.PRE_COMPUTE, matching its siblings.zip_with_nextinherently needs the whole sequence (it pairs elementiwithi+1), so pre-computing is correct and does not change its semantics.Verification
test_zip_with_next_after_lazy_transform(serial + parallel).