FillArrays.jl icon indicating copy to clipboard operation
FillArrays.jl copied to clipboard

Preserve axes in `permutedims`

Open jishnub opened this issue 2 years ago • 1 comments

The vector method is unnecessary, as the fallback Base method uses reshape, which will do the same.

For the other method: On master,

julia> F = Fill(2, (SOneTo(2), SOneTo(3)))
2×3 Fill{Int64, 2, Tuple{SOneTo{2}, SOneTo{3}}} with indices SOneTo(2)×SOneTo(3), with entries equal to 2

julia> permutedims(F)
3×2 Fill{Int64, 2, Tuple{SOneTo{3}, SOneTo{2}}} with indices SOneTo(3)×SOneTo(2), with entries equal to 2

julia> permutedims(F, (2,1))
3×2 Fill{Int64}, with entries equal to 2

In the second operation, the static axes are lost. After this PR, the axes are preserved:

julia> permutedims(F, (2,1))
3×2 Fill{Int64, 2, Tuple{SOneTo{3}, SOneTo{2}}} with indices SOneTo(3)×SOneTo(2), with entries equal to 2

To make this type-stable, we require aggressive constant propagation on the permutation tuple.

jishnub avatar Dec 05 '23 06:12 jishnub

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (6f61dc3) to head (899b469).

Files with missing lines Patch % Lines
src/fillalgebra.jl 0.00% 7 Missing :warning:

:exclamation: There is a different number of reports uploaded between BASE (6f61dc3) and HEAD (899b469). Click for more details.

HEAD has 10 uploads less than BASE
Flag BASE (6f61dc3) HEAD (899b469)
19 9
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #319       +/-   ##
==========================================
- Coverage   99.91%   0.00%   -99.92%     
==========================================
  Files           8       8               
  Lines        1147    1145        -2     
==========================================
- Hits         1146       0     -1146     
- Misses          1    1145     +1144     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 05 '23 06:12 codecov[bot]

@jishnub I just came across a need for this, can this be merged?

mtfishman avatar Aug 16 '25 22:08 mtfishman