You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The IteratorSize doc string says that if its return value is IsInfinite(), "the iterator yields values forever". The iterator returned by Iterators.cycle is documented to be empty in some cases, even though it seems to always be an infinite iterator currently:
julia> it = Iterators.cycle(())
Base.Iterators.Cycle{Tuple{}}(())
julia> isempty(it)
true
julia> iterate(it)
julia> Base.IteratorSize(typeof(it))
Base.IsInfinite()
julia> versioninfo()
Julia Version 1.11.0-DEV.1451
Commit f117a500ca9 (2024-02-01 15:38 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Not sure what's a good fix, perhaps make Iterators.cycle return () when it's given an empty iterator as input. This wouldn't always be type stable, though.
The text was updated successfully, but these errors were encountered:
nsajko
added
bug
Indicates an unexpected problem or unintended behavior
collections
Data structures holding multiple items, e.g. sets
iteration
Involves iteration or the iteration protocol
correctness bug ⚠
Bugs that are likely to lead to incorrect results in user code without throwing
labels
Feb 3, 2024
The
IteratorSize
doc string says that if its return value isIsInfinite()
, "the iterator yields values forever". The iterator returned byIterators.cycle
is documented to be empty in some cases, even though it seems to always be an infinite iterator currently:Not sure what's a good fix, perhaps make
Iterators.cycle
return()
when it's given an empty iterator as input. This wouldn't always be type stable, though.The text was updated successfully, but these errors were encountered: