Skip to content

Support boolean datalayout indexing #2277

@charleskawczynski

Description

@charleskawczynski

For Julia arrays, users can do things like:

julia> A = rand(3,3)
3×3 Matrix{Float64}:
 0.628506  0.704686   0.205372
 0.390219  0.192054   0.118027
 0.27103   0.0604534  0.297599

julia> A[A .> 0.5] .= 1
2-element view(::Vector{Float64}, [1, 4]) with eltype Float64:
 1.0
 1.0

julia> A
3×3 Matrix{Float64}:
 1.0       1.0        0.205372
 0.390219  0.192054   0.118027
 0.27103   0.0604534  0.297599

It would be really convenient for users if we could somehow support this with DataLayouts, specifically for AbstractData{Bool} fields.

This may be a bit a bit of work to support getindex and setindex!, since setindex! will require some sort of lazy view, containing the indices, but I think it's possible in principle.

This might be a nice complement to the space masks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions