-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 #30643, correctly propagate iterator traits through Stateful #30644
Conversation
Not sure what the previous definition of IteratorSize was trying to do, but it was wrong for IsInfinite. Not sure what the correct answer is for HasShape.
Anyone have a good test case for this? |
julia> Base.IteratorSize(Iterators.Stateful(Iterators.cycle(1:10)))
Base.HasLength()
This should be IsInfinite().
…On Tue, Jan 8, 2019 at 9:49 AM Stefan Karpinski ***@***.***> wrote:
Anyone have a good test case for this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30644 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvNpkwe7fG6arewwVciyuLYctBtjaObks5vBK_xgaJpZM4Z0x6r>
.
|
Could you add that test to test/iterators.jl? |
@@ -1089,10 +1089,9 @@ end | |||
|
|||
@inline peek(s::Stateful, sentinel=nothing) = s.nextvalstate !== nothing ? s.nextvalstate[1] : sentinel | |||
@inline iterate(s::Stateful, state=nothing) = s.nextvalstate === nothing ? nothing : (popfirst!(s), nothing) | |||
IteratorSize(::Type{Stateful{VS,T}} where VS) where {T} = |
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 quite remember what the intent here was, but it may have been to filter out HasSize
, since we don't pass that through (and can't really support).
So Stateful should change HasSize to HasLength?
…On Tue, Jan 8, 2019, 1:42 PM Keno Fischer ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In base/iterators.jl
<#30644 (comment)>:
> @@ -1089,10 +1089,9 @@ end
@inline peek(s::Stateful, sentinel=nothing) = s.nextvalstate !== nothing ? s.nextvalstate[1] : sentinel
@inline iterate(s::Stateful, state=nothing) = s.nextvalstate === nothing ? nothing : (popfirst!(s), nothing)
-IteratorSize(::Type{Stateful{VS,T}} where VS) where {T} =
I don't quite remember what the intent here was, but it may have been to
filter out HasSize, since we don't pass that through (and can't really
support).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30644 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvNpitwt1pb6d4aUmRkN4aWUzXArQUIks5vBOaEgaJpZM4Z0x6r>
.
|
Yeah, I think that's right. |
Should be backported? |
Yes. |
Not sure what the previous definition of IteratorSize was trying to do, but it was wrong for IsInfinite. Not sure what the correct answer is for HasShape.