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

Could the definition of similar_type move here? #3

Closed
ChrisRackauckas opened this issue Jun 25, 2022 · 8 comments · Fixed by #5
Closed

Could the definition of similar_type move here? #3

ChrisRackauckas opened this issue Jun 25, 2022 · 8 comments · Fixed by #5

Comments

@ChrisRackauckas
Copy link
Member

SciML/LabelledArrays.jl#122

It really should be in Base, but 🤷

@mateuszbaran
Copy link
Collaborator

Yes, that's reasonable.

@mateuszbaran
Copy link
Collaborator

I guess you also need the Size type and all similar_type methods it enables?

@ChrisRackauckas
Copy link
Member Author

@mateuszbaran
Copy link
Collaborator

OK, so #5 is enough?

@devmotion
Copy link

This would be useful for ForwardDiff as well, it seems, as it uses similar_type in its implementations for StaticArrays.

Ref: JuliaDiff/ForwardDiff.jl#591

@N5N3
Copy link
Contributor

N5N3 commented Aug 21, 2022

I don't, https://github.com/SciML/LabelledArrays.jl/pull/122/files#diff-918dda16160ab68d9766c22082a5c3463aef402c63fdf25244313c9f2bde525eR40

but I don't know if that's common. I worked around any Size issues like https://github.com/SciML/LabelledArrays.jl/pull/122/files#diff-918dda16160ab68d9766c22082a5c3463aef402c63fdf25244313c9f2bde525eR162

@ChrisRackauckas looks like you still need the Size struct?

function StaticArrays.similar_type(::Type{SLArray{S, T, N, L, Syms}}, ::Type{NewElType},
                                   ::Size{NewSize}) where {S, T, N, L, Syms, NewElType, # used here
                                                           NewSize}

@ChrisRackauckas
Copy link
Member Author

It can be worked around.

@N5N3
Copy link
Contributor

N5N3 commented Aug 21, 2022

Do you mean

function StaticArrays.similar_type(::Type{SLArray{S, T, N, L, Syms}}, ::Type{NewElType}, sz) where {S, T, N, L, Syms, NewElType}

?
This would cause ambiguity as we have

  similar_type(::Type{A}, ::Type{T}, s::Size{S}) where {A<:AbstractArray, T, S}

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 a pull request may close this issue.

4 participants