You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the FAQ it is explained why conversion of a Vector to an SVector is not allowed. While I'm not sure I agree with this, if the current behaviour is kept then the error message should be explanatory: instead of
julia>convert(SVector,[1,2,3])
ERROR: MethodError: Cannot `convert` an object of type Type{StaticArrays.SArray{Tuple{S},T,1,S} where T where S} to an object of type StaticArrays.Size
This may have arisen from a call to the constructor StaticArrays.Size(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] convert(::Type{StaticArrays.SArray{Tuple{S},T,1,S} where T where S}, ::Array{Int64,1}) at /Users/solver/.julia/v0.6/StaticArrays/src/convert.jl:17
It should say something like "Converting vectors to static vectors is not allowed to avoid type instability. Instead, use ...".
The text was updated successfully, but these errors were encountered:
I guess we could work around this and add messages to SArray, SMatrix, SizedArray, MVector, etc. I kind of expected that one to be fixed before they released v0.6, but oh well.
We now have the following error which solves this issue:
julia> convert(SVector, [1,2])
ERROR: The size of type `SArray{Tuple{S},T,1,S} where T where S` is not known.
If you were trying to construct (or `convert` to) a `StaticArray` you
may need to add the size explicitly as a type parameter so its size is
inferrable to the Julia compiler (or performance would be terrible). For
example, you might try
m = zeros(3,3)
SMatrix(m) # this error
SMatrix{3,3}(m) # correct - size is inferrable
In the FAQ it is explained why conversion of a
Vector
to anSVector
is not allowed. While I'm not sure I agree with this, if the current behaviour is kept then the error message should be explanatory: instead ofIt should say something like "Converting vectors to static vectors is not allowed to avoid type instability. Instead, use ...".
The text was updated successfully, but these errors were encountered: