JuliaArrays / AxisArrays.jl

Performant arrays where each dimension can have a named axis with values
http://JuliaArrays.github.io/AxisArrays.jl/latest/
Other
200 stars 41 forks source link

Add `UndefInitializer` #168

Open nickrobinson251 opened 5 years ago

nickrobinson251 commented 5 years ago

It would be nice if it were possible to construct an AxisArray with AxisArray(undef, axes::Axis...)

e.g. such that

A1 = AxisArray(undef, Axis{:a}(1:2), Axis{:b}(1:3), Axis{:c}(1:4)
@test A1 == AxisArray(Array{Any,3}(undef, 2, 3, 4), Axis{:a}(1:2), Axis{:b}(1:3), Axis{:c}(1:4));

A2 = AxisArray(undef, Axis{:a}(), Axis{:b}())
@test A2 == AxisArray(Matrix(undef, 0, 0), Axis{:a}(), Axis{:b}())

Currently this is a method error (v0.3.2):

julia> AxisArray(undef, Axis{:a}(), Axis{:b}())
ERROR: MethodError: no method matching AxisArray(::UndefInitializer, ::Axis{:a,Tuple{}}, ::Axis{:b,Tuple{}})