Skip to content

Commit

Permalink
Update vectorized_product_iterator.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Apr 6, 2021
1 parent e2e9d32 commit 591c63a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Containers/vectorized_product_iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ struct VectorizedProductIterator{T}
prod::Iterators.ProductIterator{T}
end

function _collect(x)
# Collect iterators with unknown size so they can be used as axes.
if Base.IteratorSize(x) == Base.SizeUnknown()
return collect(x)
elseif Base.IteratorSize(x) == Base.IsInfinite()
error("Unable to form a container. Axis $(x) has infinite size!")
else
return x
end
# Collect iterators with unknown size so they can be used as axes.
_collect(::Base.SizeUnknown, x) = collect(x)
_collect(::Any, x) = x
function _collect(::Base.IsInfinite, x)
return error("Unable to form a container. Axis $(x) has infinite size!")
end
_collect(x) = _collect(Base.IteratorSize(x), x)

function vectorized_product(iterators...)
return VectorizedProductIterator(Iterators.product(_collect.(iterators)...))
Expand Down

0 comments on commit 591c63a

Please sign in to comment.