-
Notifications
You must be signed in to change notification settings - Fork 153
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
Preserve more FieldArray
s with parametric eltype
.
#1064
base: master
Are you sure you want to change the base?
Conversation
c6e2676
to
afc9759
Compare
And return a `MArray` for mutable `FieldArray`
This code is likely wrong, as mentioned in the manual for the purpose of this function: |
src/FieldArray.jl
Outdated
# FieldArrays with parametric `eltype` would be adapted to the new `eltype` automatically. | ||
A′ = Base.typeintersect(base_type(A), StaticArray{Tuple{Tuple(S)...},T,length(S)}) | ||
# But extra parameters are disallowed here. Also we check `fieldtypes` to make sure the result is valid. | ||
isconcretetype(A′) && fieldtypes(A′) === ntuple(Returns(T), Val(prod(S))) && return A′ |
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.
I still think this branch is useful for FieldArrays
with only one parameter for eltype
.
Check in L134 seems sufficient for me, as a concrete type with matched fieldtypes
should be valid to return.
The `typeintersect` must return a concrete type now. And it's `fieldtypes` should match our doc example.
Before this PR, user needs to define
similar_type
for their ownFieldArray
s with parametriceltype
.After this PR, these
FieldArray
s would be preserved automatically if there's noSize
change. (Inspired by JuliaLang/julia#46213)This PR also change the default similar type for mutable
FieldArray
toMArray
.