You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionismutable(::Type{T}) where {T<:AbstractArray}
ifparent_type(T) <:Treturnfalse# no parent, and have not hit a type we know about elsereturnismutable(parent_type(T))
endend
ismutable{::Type{<:Array}} =true
ismutable{::Type{<:SparseVector}} =true
ismutable{::Type{<:SparseMatrixCSC}} =true
ismutable{::Type{<:BitArray}} =true
Alternatively
the fallback case could be: return T.mutable rather than false.
On the assumption that if you are a mutable struct that has subtypes AbstractArray you probably have defined setindex
I like the idea of mutability being something that needs to be opted into. I didn't originally make true the default, so I'm assuming that decision reflected that the majority of the ecosystem uses Array and parent_type wasn't a method at the time to dig into wrappers.
basically anything that is mutable will eventually parent it's way up a fundermentally mutable backing array type, probably Array.
Immutable things, like StaticArrays and FillArrays tend not to have parents in the first place
Should we suggest using ArrayInterface.can_setindex and ArrayInterface.can_change_size in documentation for most arrays since these methods are more specific?
I assume all AbstractFill are immutable? If that's true, we should just make an extension library for FillArrays that does that. I'll wait until someone who knows FillArrays.jl better responds and makes sure that's true.
Activity
Tokazama commentedon Oct 14, 2020
I like the idea of mutability being something that needs to be opted into. I didn't originally make
truethe default, so I'm assuming that decision reflected that the majority of the ecosystem usesArrayandparent_typewasn't a method at the time to dig into wrappers.Does this break anything.
chriselrod commentedon Oct 14, 2020
How many libraries are currently using
ArrayInterface.jl?It's easy enough to test a small handful locally, like
DifferentialEquations.jl.Barring breaking a bunch of stuff, I think it's okay to make
falsethe default.oxinabox commentedon Oct 14, 2020
basically anything that is mutable will eventually
parentit's way up a fundermentally mutable backing array type, probablyArray.Immutable things, like
StaticArrays andFillArraystend not to haveparents in the first placeTokazama commentedon Mar 7, 2022
Should we suggest using
ArrayInterface.can_setindexandArrayInterface.can_change_sizein documentation for most arrays since these methods are more specific?ChrisRackauckas commentedon Mar 7, 2022
No,
can_setindexis different, for example, with GPUs.ChrisRackauckas commentedon Feb 18, 2023
I assume all AbstractFill are immutable? If that's true, we should just make an extension library for FillArrays that does that. I'll wait until someone who knows FillArrays.jl better responds and makes sure that's true.