Preserve more FieldArrays with parametric eltype.#1064
Open
N5N3 wants to merge 3 commits intoJuliaArrays:masterfrom
Open
Preserve more FieldArrays with parametric eltype.#1064N5N3 wants to merge 3 commits intoJuliaArrays:masterfrom
FieldArrays with parametric eltype.#1064N5N3 wants to merge 3 commits intoJuliaArrays:masterfrom
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: |
N5N3
commented
Aug 2, 2022
src/FieldArray.jl
Outdated
Comment on lines
131
to
134
| # 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′ |
Contributor
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR, user needs to define
similar_typefor their ownFieldArrays with parametriceltype.After this PR, these
FieldArrays would be preserved automatically if there's noSizechange. (Inspired by JuliaLang/julia#46213)This PR also change the default similar type for mutable
FieldArraytoMArray.