Skip to content

Support construction/conversion of UnitRange->SOneTo #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2018
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Nov 22, 2018

Discovered in the context of

julia> a = SVector(SVector(1,2), SVector(3,4))
2-element SArray{Tuple{2},SArray{Tuple{2},Int64,1,2},1,2}:                                                                                                                                                                                                                     
 [1, 2]                                                                                                                                                                                                                                                                        
 [3, 4]                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                             
julia> a'
1×2 LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},SArray{Tuple{2},SArray{Tuple{2},Int64,1,2},1,2}}:                                                                                                                                                                                          
 [1 2]  [3 4]                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                             
julia> reinterpret(Int, a')
Error showing value of type Base.ReinterpretArray{Int64,2,LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},SArray{Tuple{2},SArray{Tuple{2},Int64,1,2},1,2}}}:                                                                           
ERROR: MethodError: no method matching SOneTo{1}(::UnitRange{Int64})                                                                                                                                                                                                                                                         
Closest candidates are:                                                                                                                                                                                                                                                                                                      
  SOneTo{1}() where n at /home/tim/.julia/packages/StaticArrays/3ENSR/src/SOneTo.jl:8                                                                                                                                                                                                                                        
Stacktrace:                                                                                                                                                                                                                                                                                                                  
 [1] convert(::Type{SOneTo{1}}, ::UnitRange{Int64}) at ./range.jl:123                                                                                                                                                                                                                                                        
 [2] oftype(::SOneTo{1}, ::UnitRange{Int64}) at ./essentials.jl:334                                                                                                                                                                                                                                                          
 [3] axes(::Base.ReinterpretArray{Int64,2,LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},SArray{Tuple{2},SArray{Tuple{2},Int64,1,2},1,2}}}) at ./reinterpretarray.jl:82                                                               
 [4] summary(::IOContext{REPL.Terminals.TTYTerminal}, ::Base.ReinterpretArray{Int64,2,LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Int64,SArray{Tuple{2},Int64,1,2}},SArray{Tuple{2},SArray{Tuple{2},Int64,1,2},1,2}}}) at ./show.jl:1824                             
...

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 66.173% when pulling abc5564 on teh/soneto into d14604c on master.

Copy link
Member

@andyferris andyferris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@andyferris
Copy link
Member

As a side note unrelated to this PR (other than making me think of it) - I wonder if UnitRange([1,2,3])(or maybe convert(UnitRange, [1,2,3])) should work since the AbstractArray interface generally supports conversion between array types?

@andyferris andyferris merged commit 53a19c3 into master Nov 23, 2018
@timholy timholy deleted the teh/soneto branch November 23, 2018 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants