Skip to content

Commit 5da20c7

Browse files
committed
Fix #53 with ismutable default
Default behavior is to use the `mutable` field of a type
1 parent 48cd97c commit 5da20c7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/ArrayInterface.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19.
7272
ismutable(x) = ismutable(typeof(x))
7373

7474
ismutable(::Type{<:AbstractArray}) = true
75-
ismutable(::Type{<:Number}) = false
7675
ismutable(::Type{<:AbstractRange}) = false
77-
ismutable(::Type{<:Tuple}) = false
76+
ismutable(::Type{<:AbstractDict}) = true
77+
ismutable(::Type{<:Base.ImmutableDict}) = false
78+
ismutable(::Type{T}) where {T} = T.mutable
7879

7980
# Piracy
8081
function Base.setindex(x::AbstractArray,v,i...)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ using StaticArrays
88
@test ArrayInterface.ismutable(@MVector [1,2,3]) == true
99
@test ArrayInterface.ismutable(1:10) == false
1010
@test ArrayInterface.ismutable((0.1,1.0)) == false
11+
@test ArrayInterface.ismutable(Base.ImmutableDict{Symbol,Int64}) == false
12+
@test ArrayInterface.ismutable((;x=1)) == false
1113
@test isone(ArrayInterface.known_first(typeof(StaticArrays.SOneTo(7))))
1214
@test ArrayInterface.known_last(typeof(StaticArrays.SOneTo(7))) == 7
1315
@test ArrayInterface.known_length(typeof(StaticArrays.SOneTo(7))) == 7
@@ -47,6 +49,7 @@ rowind,colind=findstructralnz(Sp)
4749
@test ArrayInterface.ismutable(spzeros(1, 1))
4850
@test ArrayInterface.ismutable(spzeros(1))
4951

52+
5053
@test !fast_scalar_indexing(qr(rand(10, 10)).Q)
5154
@test !fast_scalar_indexing(qr(rand(10, 10), Val(true)).Q)
5255
@test !fast_scalar_indexing(lq(rand(10, 10)).Q)

0 commit comments

Comments
 (0)