JuliaArrays / FillArrays.jl

Julia package for lazily representing matrices filled with a single entry
https://juliaarrays.github.io/FillArrays.jl/
MIT License
182 stars 39 forks source link

overload permutedims for OneElement matrices #368

Closed max-vassili3v closed 1 month ago

max-vassili3v commented 1 month ago

overload permutedims for OneElementMatrix to return OneElement

jishnub commented 1 month ago

This may be more general, no?

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.90%. Comparing base (f659d9f) to head (e84270d). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #368 +/- ## ======================================= Coverage 99.90% 99.90% ======================================= Files 8 8 Lines 1106 1110 +4 ======================================= + Hits 1105 1109 +4 Misses 1 1 ```

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

dlfivefifty commented 1 month ago

@max-vassili3v Can you add this for more general OneElement? At the very least OneElementVector.

max-vassili3v commented 1 month ago

Implemented for more general OneElements, I originally excluded the implementation for OneElementVector since permutedims(::AbstractVector) uses reshape which keeps it as a OneElement

jishnub commented 1 month ago

Incidentally, the vector case already works on master, although we perhaps need a specialized method anyway. Perhaps we may define the method in terms of the reshape, as in Base. This way, it'll stay consistent.

julia> o = OneElement(1, 1, 2)
2-element OneElement{Int64, 1, Tuple{Int64}, Tuple{Base.OneTo{Int64}}}:
 1
 ⋅

julia> permutedims(o)
1×2 OneElement{Int64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}:
 1  ⋅