CliMA / CliMA/ClimaCore.jl

Support boolean datalayout indexing

Open
#2,277 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 5h
Merged PRs (30d)
36

Description

For Julia arrays, users can do things like:

```julia
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.