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

mapslices errors for AxisArrays #193

Open glennmoy opened 3 years ago

glennmoy commented 3 years ago

Trying to call mapslices over an AxisArray errors which I think can be fixed with the appropriate method for reduce_indices.

This seems somewhat related to #7.

MWE:

julia> A = AxisArray(collect(reshape(1:15,3,5)), :y, :x)
2-dimensional AxisArray{Int64,2,...} with axes:
    :y, Base.OneTo(3)
    :x, Base.OneTo(5)
And data, a 3×5 Array{Int64,2}:
 1  4  7  10  13
 2  5  8  11  14
 3  6  9  12  15

julia> mapslices(sum, A; dims=1)
ERROR: MethodError: no method matching reduced_indices(::Tuple{Axis{:y,UnitRange{Int64}}}, ::UnitRange{Int64})
Closest candidates are:
  reduced_indices(::Tuple{Vararg{Axis,N} where N}, ::Tuple{}) at /Users/glenn/.julia/dev/AxisArrays/src/core.jl:350
  reduced_indices(::Tuple{Vararg{Axis,N} where N}, ::Integer) at /Users/glenn/.julia/dev/AxisArrays/src/core.jl:352
  reduced_indices(::Tuple{Vararg{Axis,N}}, ::Tuple{Vararg{Int64,N}} where N) where N at /Users/glenn/.julia/dev/AxisArrays/src/core.jl:357
  ...
Stacktrace:
 [1] reduced_indices(::AxisArray{Int64,1,Array{Int64,1},Tuple{Axis{:y,UnitRange{Int64}}}}, ::UnitRange{Int64}) at /Users/glenn/.julia/dev/AxisArrays/src/core.jl:347
 [2] mapslices(::typeof(sum), ::AxisArray{Int64,2,Array{Int64,2},Tuple{Axis{:y,Base.OneTo{Int64}},Axis{:x,Base.OneTo{Int64}}}}; dims::Int64) at ./abstractarray.jl:2098
 [3] top-level scope at REPL[90]:1