Skip to content
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

Move Size to StaticArraysCore.jl #1094

Merged
merged 1 commit into from
Sep 23, 2022
Merged

Move Size to StaticArraysCore.jl #1094

merged 1 commit into from
Sep 23, 2022

Conversation

mateuszbaran
Copy link
Collaborator

@thchr thchr marked this pull request as ready for review September 21, 2022 13:50
@thchr thchr marked this pull request as draft September 21, 2022 13:50
@thchr
Copy link
Collaborator

thchr commented Sep 21, 2022

This LGTM.

Comment on lines 14 to 19
Size(::Type{Adjoint{T, A}}) where {T, A <: AbstractVecOrMat{T}} = Size(Size(A)[2], Size(A)[1])
Size(::Type{Transpose{T, A}}) where {T, A <: AbstractVecOrMat{T}} = Size(Size(A)[2], Size(A)[1])
Size(::Type{Symmetric{T, A}}) where {T, A <: AbstractMatrix{T}} = Size(A)
Size(::Type{Hermitian{T, A}}) where {T, A <: AbstractMatrix{T}} = Size(A)
Size(::Type{Diagonal{T, A}}) where {T, A <: AbstractVector{T}} = Size(Size(A)[1], Size(A)[1])
Size(::Type{<:LinearAlgebra.AbstractTriangular{T, A}}) where {T,A} = Size(A)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be moved to StaticArraysCore as well? Technically it is type piracy.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are some additional definitions below with types from base.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

StaticArraysCore currently doesn't import LinearAlgebra so that's why I didn't more them. Is there a use for these methods in StaticArraysCore without StaticArrays?

I know this is type piracy but it should be harmless since StaticArrays in practice "owns" Size.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is type piracy but it should be harmless since StaticArrays in practice "owns" Size.

That's why I assumed it is mostly technical. It would only become an issue if some other package wants to use these Size functionalities without depending on StaticArrays itself.

Some of the definitions below don't even use LinearAlgebra (or some other standard library), e.g., Base.prod or definitions for Tuples.

Generally, I would assume that it's fine for StaticArraysCore to depend on LinearAlgebra as it is a standard library and I think usually any package with StaticArraysCore in the dependency tree will have LinearAlgebra in the dependency tree anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the PR to core is already merged and tagged, let's leave that to a new PR.

Copy link
Member

Choose a reason for hiding this comment

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

Basically all of StaticArrays is type piracy, e.g. *(::SMatrix, ::SVector) is type piracy since StaticArrays owns neither the function nor the types.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might actually not only be a theoretical problem but cause issues with generated functions: JuliaDiff/ForwardDiff.jl#599 (comment)

@mateuszbaran mateuszbaran marked this pull request as ready for review September 22, 2022 08:22
@mateuszbaran mateuszbaran merged commit 5f7debb into master Sep 23, 2022
@mateuszbaran mateuszbaran deleted the mbaran/move-size branch September 23, 2022 09:22
@mcabbott
Copy link
Collaborator

Maybe some functions like length(::Type{StaticArraysCore.SMatrix... need to move here too?

Defining them later in StaticArrays seems to cause problems for @generated functions, here: JuliaDiff/ForwardDiff.jl#599 (comment) .

@mateuszbaran
Copy link
Collaborator Author

I think moving length would be fine. Note though that we can't put too much functionality into SACore.jl, I'd like to see a clear use for each function/method/type that is put there so porting packages as complicated as ForwardDiff.jl may take some time.

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.

5 participants