Skip to content

checkbounds with keyword arguments #1156

@penelopeysm

Description

@penelopeysm

I'd like to be able to check whether I can index into a DimArray. With most AbstractArrays this can be done with Base.checkbounds, but there isn't an overload for DimArray that accepts keyword arguments. Should there be one? (And if not, what's the best way for me to check whether I can index in?)

julia> x = DimArray(rand(2, 3), (:a, :b))
┌ 2×3 DimArray{Float64, 2} ┐
├──────────────────── dims ┤
   a,  b
└──────────────────────────┘
 0.737598  0.621954  0.0407873
 0.303194  0.466593  0.763799

julia> x[a=1]
┌ 3-element DimArray{Float64, 1} ┐
├────────────────────────── dims ┤
   b
└────────────────────────────────┘
 0.737598
 0.621954
 0.0407873

julia> checkbounds(Bool, x; a=1)
ERROR: MethodError: no method matching checkbounds(::Type{…}, ::DimMatrix{…}; a::Int64)
This method may not support any kwargs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions