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

Allow atvalue indexing in categorical axes #107

Merged
merged 1 commit into from
Aug 13, 2017

Conversation

iamed2
Copy link
Collaborator

@iamed2 iamed2 commented Aug 11, 2017

julia> using AxisArrays

julia> using AxisArrays: CategoricalVector

julia> A = AxisArray(zeros(3,3), Axis{:a1}(CategoricalVector([1,55,9])), Axis{:a2}([11,22,33]))
2-dimensional AxisArray{Float64,2,...} with axes:
    :a1, [1, 55, 9]
    :a2, [11, 22, 33]
And data, a 3×3 Array{Float64,2}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0

Previously:

julia> A[atvalue(55), atvalue(22)]
ERROR: ArgumentError: index Value(55, tol=0) not found
Stacktrace:
 [1] axisindexes(::Type{AxisArrays.Categorical}, ::AxisArrays.CategoricalVector{Int64,Array{Int64,1}}, ::AxisArrays.Value{Int64}) at /Users/ericdavies/.julia/v0.6/AxisArrays/src/indexing.jl:249
 [2] getindex(::AxisArrays.AxisArray{Float64,2,Array{Float64,2},Tuple{AxisArrays.Axis{:a1,AxisArrays.CategoricalVector{Int64,Array{Int64,1}}},AxisArrays.Axis{:a2,Array{Int64,1}}}}, ::AxisArrays.Value{Int64}, ::AxisArrays.Value{Int64}) at /Users/ericdavies/.julia/v0.6/AxisArrays/src/indexing.jl:98

Now:

julia> A[atvalue(55), atvalue(22)]
0.0

@ajkeller34
Copy link
Collaborator

LGTM, but I will wait a day to merge in case someone else has comments.

@ajkeller34 ajkeller34 merged commit fd2a6a5 into JuliaArrays:master Aug 13, 2017
@iamed2 iamed2 deleted the categorical-atvalue branch August 14, 2017 02:09
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

Successfully merging this pull request may close these issues.

None yet

2 participants