Slicing an `SArray` with a `CartesianIndices(::StaticArray)` may return an `SArray`

Open
#1,059 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
data

Research direction

Start by reproducing the SMatrix slicing examples with axes(m3) and CartesianIndices(m3) in the Julia REPL. Trace the indexing entry point for CartesianIndices over StaticArrays and add or update coverage for the result type; done means both forms return the intended SArray type with the shown values.

Written by the indexing model from the issue text.

Description

Currently,

julia> m4 = SMatrix{4,4,Int,16}(1:16)
4×4 SMatrix{4, 4, Int64, 16} with indices SOneTo(4)×SOneTo(4):
 1  5   9  13
 2  6  10  14
 3  7  11  15
 4  8  12  16

julia> m3 = SMatrix{3,3,Int,9}(1:9)
3×3 SMatrix{3, 3, Int64, 9} with indices SOneTo(3)×SOneTo(3):
 1  4  7
 2  5  8
 3  6  9

julia> m4[axes(m3)...]
3×3 SMatrix{3, 3, Int64, 9} with indices SOneTo(3)×SOneTo(3):
 1  5   9
 2  6  10
 3  7  11

julia> m4[CartesianIndices(m3)]
3×3 MMatrix{3, 3, Int64, 9} with indices SOneTo(3)×SOneTo(3):
 1  5   9
 2  6  10
 3  7  11

I think this may return an SMatrix as well

Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaArrays/StaticArrays.jl

All issues in JuliaArrays/StaticArrays.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.