Skip to content

Conversation

@jishnub
Copy link
Member

@jishnub jishnub commented May 8, 2024

After this, reshapeing a OneElement returns a OneElement.

julia> A = OneElement(2, (2,2), (2,3))
2×3 OneElement{Int64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}:
     
   2  

julia> reshape(A, (1,6))
1×6 OneElement{Int64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}:
       2    

julia> reshape(A, (6,))
6-element OneElement{Int64, 1, Tuple{Int64}, Tuple{Base.OneTo{Int64}}}:
 
 
 
 2
 
 

This uses the fact that the linear indices are preserved under a reshape to compute the new Cartesian index of the non-zero value.

@codecov
Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.90%. Comparing base (39df7ec) to head (b4a19a7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #365   +/-   ##
=======================================
  Coverage   99.90%   99.90%           
=======================================
  Files           8        8           
  Lines        1073     1078    +5     
=======================================
+ Hits         1072     1077    +5     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jishnub jishnub merged commit 4f8a966 into master May 9, 2024
@jishnub jishnub deleted the jishnub/reshapeoneel branch May 9, 2024 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants