-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]designDesign of APIs or of the language itselfDesign of APIs or of the language itselfdocsThis change adds or pertains to documentationThis change adds or pertains to documentation
Description
The documentation says Array
help?> collect
...
collect(collection)
Return an Array of all items in a collection or iterator. For dictionaries, returns Pair{KeyType, ValType}. If the argument is array-like or is an iterator with the HasShape trait, the result will have the same shape and number of dimensions as the argument.but collect of Iterators.product breaks this promise:
julia> Iterators.product(OffsetArray(rand(3), -1:1), 1:2) |> collect
3×2 OffsetArray(::Matrix{Tuple{Float64, Int64}}, -1:1, 1:2) with eltype Tuple{Float64, Int64} with indices -1:1×1:2:
(0.892917, 1) (0.892917, 2)
(0.398366, 1) (0.398366, 2)
(0.550785, 1) (0.550785, 2)I think returning an AbstractArray is fine if the documentation is updated. Interestingly collect(collect()) results in a normal Array. So OffsetArrays is following the documentation.
LilithHafner
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]designDesign of APIs or of the language itselfDesign of APIs or of the language itselfdocsThis change adds or pertains to documentationThis change adds or pertains to documentation