Hi there, someone pointed out this package to me when I tried to solve the same problem resulting in ProductArrays currently in the registering process. It might make sense to stop its publishing now, but I also noticed that you did not cover a few edge cases making the behavior of StructuredGrid not quite the same as the collected product.Iterator
. This is something ProductArray promises (I would count any failure to do so as a bug). Here are the edge cases:
julia> grid([1 2; 3 4], [:a, :b])
2×2 StructuredGrids.Grid{Tuple{Int64, Symbol}, 2, Tuple{Matrix{Int64}, Vector{Symbol}}}:
(1, :a) (1, :b)
(3, :a) (3, :b)
julia> Iterators.product([1 2; 3 4], [:a, :b]) |> collect
2×2×2 Array{Tuple{Int64, Symbol}, 3}:
[:, :, 1] =
(1, :a) (2, :a)
(3, :a) (4, :a)
[:, :, 2] =
(1, :b) (2, :b)
(3, :b) (4, :b)
julia> grid(1:2, (:a, :b))
Error showing value of type StructuredGrids.Grid{Tuple{Int64, Symbol}, 2, Tuple{UnitRange{Int64}, Tuple{Symbol, Symbol}}}:
ERROR: MethodError: no method matching axes(::Tuple{Symbol, Symbol}, ::Int64)
Closest candidates are:
axes(::Tuple) at tuple.jl:28
axes(::Number, ::Integer) at number.jl:83
axes(::Base.Broadcast.Broadcasted{<:Any, <:Tuple{Vararg{T, N}} where T}, ::Integer) where N at broadcast.jl:227
...
Stacktrace:
[1] _axes (repeats 2 times)
@ ~/.julia/packages/StructuredGrids/ndiJn/src/StructuredGrids.jl:17 [inlined]
...