Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select by axis values doesn't preserve the order #182

Open
wytbella opened this issue May 29, 2020 · 1 comment
Open

Select by axis values doesn't preserve the order #182

wytbella opened this issue May 29, 2020 · 1 comment

Comments

@wytbella
Copy link

When selecting an AxisArray by index, it returns the correct order as expected. However, if one selects by axis values, it doesn’t preserve the order (see example below).

julia> tmp = AxisArray(rand(2,3), x=[:a, :b], y=[:A, :B, :C])
2-dimensional AxisArray{Float64,2,...} with axes:
    :x, [:a, :b]
    :y, [:A, :B, :C]
And data, a 2×3 Array{Float64,2}:
 0.373003  0.355006  0.158701
 0.691354  0.277119  0.651728
julia> tmp[[2,1],:]
2-dimensional AxisArray{Float64,2,...} with axes:
    :x, [:b, :a]
    :y, [:A, :B, :C]
And data, a 2×3 Array{Float64,2}:
 0.691354  0.277119  0.651728
 0.373003  0.355006  0.158701
julia> tmp[[:b, :a],:]
2-dimensional AxisArray{Float64,2,...} with axes:
    :x, [:a, :b]
    :y, [:A, :B, :C]
And data, a 2×3 Array{Float64,2}:
 0.373003  0.355006  0.158701
 0.691354  0.277119  0.651728
@mcabbott
Copy link
Contributor

And worse if you repeat them:

julia> tmp[[2, 1, 1], :]
2-dimensional AxisArray{Float64,2,...} with axes:
    :x, [:b, :a, :a]
    :y, [:A, :B, :C]
And data, a 3×3 Array{Float64,2}:
 0.352127  0.787136  0.725084
 0.521467  0.939554  0.828499
 0.521467  0.939554  0.828499

julia> tmp[[:b, :a, :a], :]
ERROR: ArgumentError: index Symbol[] not found
Stacktrace:
 [1] axisindexes(::Type{AxisArrays.Categorical}, ::Array{Symbol,1}, ::Array{Symbol,1}) at /Users/me/.julia/packages/AxisArrays/IFpjG/src/indexing.jl:329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants