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 multidimensional array indexing with any eltype #12273

Merged
merged 2 commits into from
Jul 27, 2015
Merged

Commits on Jul 26, 2015

  1. Allow multidimensional array indexing with any eltype

    This enables the use of the multidimensional abstract array indexing fallbacks for all element types.  In particular, this fixes #12271: `A[[]]`.  It also allows indexing with `A[Any[1,2,3]]`.  I think this is a good direction in general, since we simply index through the array and pass along the elements to a scalar indexing method.  If the `AbstractArray` subtype doesn't support indexing with those elements, then it'll throw an error there.  But I think this starts allowing fancier capabilities in packages, like indexing with an array of Dual numbers.
    mbauman committed Jul 26, 2015
    Configuration menu
    Copy the full SHA
    9e1ce9d View commit details
    Browse the repository at this point in the history
  2. Convert to_index before checkbounds in scalar indexing

    I think the behavior here is more flexible and gives better error messages at the same time:
    
    ```jl
    julia> A[[]]
    0-element Array{Int64,1}
    
    julia> A[im]
    ERROR: indexing Array{Int64,3} with types Tuple{Complex{Bool}} is not supported
     in error at ./error.jl:21
     in getindex at abstractarray.jl:463
    
    julia> A[[im]]
    ERROR: ArgumentError: unable to check bounds for indices of type Complex{Bool}
     in getindex at abstractarray.jl:463
    
    julia> A[Vector[[1,2],[3,4]]]
    ERROR: ArgumentError: invalid index: Array{T,1}[[1,2],[3,4]]
     in getindex at abstractarray.jl:463
    ```
    mbauman committed Jul 26, 2015
    Configuration menu
    Copy the full SHA
    47e24ec View commit details
    Browse the repository at this point in the history