JuliaArrays / JuliaArrays/StaticArrays.jl
How to overload similar_type for FieldVector?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
I am really confused by the documentation on what I need to do to get FieldVector to work correctly regarding similar and similar_type.
I have:
struct CylindricalStress{T<:Number} <: FieldVector{3,T}
r::T
θ::T
z::T
end
Somewhere later my type is reverted to 3-element StaticArraysCore.MVector{3, Float64} with indices SOneTo(3).
The similar_type documentation shows four "relavent" methods but then says to "only overload the last method"? I don't know what any of those similar_type methods are doing or what I should be doing with them. What is A? What if I don't know my ElType? I don't want to change my element type or size, so why do I need to use the last method? Why do none of the options have <: FieldVector? I'm totally lost.
similar_type(::Type{A}) where {A <: StaticArray} # defaults to A
similar_type(::Type{A}, ::Type{ElType}) where {A <: StaticArray, ElType} # Change element type
similar_type(::Type{A}, size::Size) where {A <: AbstractArray} # Change size
similar_type(::Type{A}, ::Type{ElType}, size::Size) where {A <: AbstractArray, ElType} # Change both
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the similar_type documentation and the FieldVector entry point mentioned in the issue. Trace the four documented method forms and how they relate to the reported conversion to MVector. Done means the documentation clearly explains the relevant method, its parameters, and how a FieldVector user keeps the intended type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100