-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
from the keys
docstring:
keys(iterator)
For an iterator or collection that has keys and values (e.g. arrays and dictionaries), return an iterator over the keys.
but a Generator
does not have keys and values. it only has values. there is no get(::Generator, ...)
nor getindex(::Generator, ...)
I believe a similar problem holds for axes(g::Generator)
and ndims(g::Generator)
, but I'm focusing on keys
since it seems the most flagrant.
this leads to awful behavior with things like
julia> d
Dict{Symbol, Int64} with 2 entries:
:a => 1
:b => -1
julia> findmax(identity, d)
(1, :a)
julia> findmax(Iterators.map(identity, d))
(:b => -1, :b)
where the second call should either error, or maybe a Generator
could 1-index as if it were an enumerate
so that would become
julia> findmax(Iterators.map(identity, d))
(:b => -1, 2)
note that
julia> iterate(Iterators.map(identity, d))
(:a => 1, 2)
so even the state
in iterate
is 1-indexed and not taking from keys(g.iter)
I think technically this is a duplicate of #48379, but I don't think the fundamental problem there has anything to do with skipmissing
so I just made a new issue.