mcabbott / AxisKeys.jl

🎹

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`reverse` doesn't act on key vectors

mcabbott opened this issue · comments

Similar to JuliaArrays/AxisArrays.jl#204

julia> A = wrapdims(rand(Int8,3,3), x=[1,10,100], y='a':'c')
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   x  3-element Vector{Int64}
   y  3-element StepRange{Char,...}
And data, 3×3 Matrix{Int8}:
         ('a')    ('b')   ('c')
   (1)  120      -24     -84
  (10)   27       22     127
 (100)  -84     -108      96

julia> reverse(A, dims=1)  # fails to reverse `A.x`
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   x  3-element Vector{Int64}
   y  3-element StepRange{Char,...}
And data, 3×3 Matrix{Int8}:
         ('a')    ('b')   ('c')
   (1)  -84     -108      96
  (10)   27       22     127
 (100)  120      -24     -84

julia> reverse(A, dims=:y)
ERROR: MethodError: no method matching _reverse!(::KeyedArray{Int8, 2, NamedDimsArray{(:x, :y), Int8, 2, Matrix{Int8}}, Tuple{Vector{Int64}, StepRange{Char, Int64}}}, ::Symbol)

julia> A[end:-1:begin, :]  # works fine
2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
   x  3-element Vector{Int64}
   y  3-element StepRange{Char,...}
And data, 3×3 Matrix{Int8}:
         ('a')    ('b')   ('c')
 (100)  -84     -108      96
  (10)   27       22     127
   (1)  120      -24     -84