-
Notifications
You must be signed in to change notification settings - Fork 152
Introduce StaticArrayLike #565
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
Conversation
Now that we have wrapper types in Base that can be used in conjunction with StaticArrays, we should discern between actual `StaticArray`s and non-`StaticArray` subtypes for which we still know a static `Size`. To this effect, this commit adds the type aliases `StaticallySizedMatrix`, `StaticallySizedVecOrMat`, and `StaticallySizedArray`, and uses them to widen various type signatures. Fixes #561.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Obviously not a general fix as people can define their own wrappers... but short of a statically sized trait system in Base to support us, there's probably not much we can do about that (?)
src/StaticArrays.jl
Outdated
@@ -78,6 +78,19 @@ const StaticVector{N, T} = StaticArray{Tuple{N}, T, 1} | |||
const StaticMatrix{N, M, T} = StaticArray{Tuple{N, M}, T, 2} | |||
const StaticVecOrMat{T} = Union{StaticVector{<:Any, T}, StaticMatrix{<:Any, <:Any, T}} | |||
|
|||
# Being a member of StaticallySizedMatrix, StaticallySizedVecOrMat, or StaticallySizedArray implies that Size(A) | |||
# returns a static Size instance. The converse may not be true. | |||
const StaticallySizedMatrix{T} = Union{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an interesting (possibly less confusing) alternative name StaticArrayLike
(/ StaticMatrixLike
) at #537 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine by me. Anybody else have opinions on the naming?
Yeah. Another case that's not handled is nested wrappers from LinearAlgebra, like |
Well, I guess this may be an improvement on the status quo but I have to admit that I do find it a bit unsatisfying - I find things like
Does this ever get constructed? It seems a little unnecessary. |
Fully agree. But I think it's just necessary given the current approach in Base.
No, no. Just a made-up example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if it is helpful, I guess we should do it. :)
My thoughts exactly. |
Did the rename and added a comment referring to |
Dang this is just crying out for a new version of Traitor.jl. Maybe a Christmas-break project... |
Now that we have wrapper types in Base that can be used in conjunction
with StaticArrays, we should discern between actual
StaticArray
s andnon-
StaticArray
subtypes for which we still know a staticSize
. Tothis effect, this PR adds the type aliases
StaticallySizedMatrix
,StaticallySizedVecOrMat
, andStaticallySizedArray
, and uses them towiden various type signatures.
Fixes #561.