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.
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 channel count upscaling #559
Fix channel count upscaling #559
Changes from all commits
6de6f22
41604cf
e6424ff
a5f0675
2f3daa9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test seems quite complex and coupled to the implementation. How about something along these lines:
If we wanted (might be overkill) we could define a custom Test iterator with a custom uncertain size_hint (I think the min and max size hints are the same for Vec since the len is known).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a point, but the thing is the tricky/most fallible part of the
size_hint
calculation is when some of the items have already been consumed, so that's the part that is most valuable to test I think.What about something like this?
But I am okay with your version if you think this is still overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make the test function generic and clone the iterator:
fn test<T>(iter: impl Iterator<Item=T> + Clone, from, to)
. Then you can pass in iterators in various states.The overkill option would be passing in a custom iterator specifically made for this test. That would look something like this:
This would allow us to test the behavior when the upper and lower bound are not the same. But I have looked around and no one implementing Iterator does something like this 😅, So lets not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the appeal of the
+ Clone
version. It seems like it'd require a lot of calls to be very useful...I think these two options are sound:
Let me know which one you think is best and I'll commit and push the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh seems like that was just me being silly there. I had the count before the size_hint (and thus consuming the iterator) which I fixed using clone. Swapping the order like you do is obv superior 👍
The idea of passing in an iterator instead of a slice is that you can pass in partially consumed iterators. You could pass in a
[1,2,3,4].into_iter().skip(3)
. Though the loop works too!The whole
i in 0..count
and thencount - i
, do you agree with replacing that withfor left_in_iter in (0..count).rev()
and(left_in_iter, Some(left_in_iter))
?I don't see any way this could improve further so push it (test_2) I'll ask est31 to take a quick look and will get it merged!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah that is better. It'll have to be
(0..=count).rev()
though.I'm also fixing a bug that caused the size_hint to go up again if calling
.next()
after the iterator was exhausted, and adding one finalassert_eq!
to test for it.