Skip to content

Commit bb33f39

Browse files
committed
fix ArrayInterface.ismutable(::ArrayPartition)
1 parent 5023a5f commit bb33f39

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.jl.*.cov
33
*.jl.mem
44
Manifest.toml
5+
.vscode

src/array_partition.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ end
7070
# ignore dims since array partitions are vectors
7171
Base.ones(A::ArrayPartition, dims::NTuple{N,Int}) where {N} = ones(A)
7272

73+
# mutable iff all components of ArrayPartition are mutable
74+
function ArrayInterface.ismutable(::Type{<:ArrayPartition{T,S}}) where {T,S}
75+
all(ArrayInterface.ismutable, S.parameters)
76+
end
77+
7378
## vector space operations
7479

7580
for op in (:+, :-)

test/partitions_test.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using RecursiveArrayTools, Test, Statistics
1+
using RecursiveArrayTools, Test, Statistics, ArrayInterface
22
A = (rand(5),rand(5))
33
p = ArrayPartition(A)
44
@test (p.x[1][1],p.x[2][1]) == (p[1],p[6])
@@ -135,3 +135,7 @@ function foo(y, x)
135135
end
136136
foo(xcde0, xce0)
137137
#@test 0 == @allocated foo(xcde0, xce0)
138+
139+
@testset "ArrayInterface.ismutable(ArrayPartition($a, $b)) == $r" for (a, b, r) in ((1,2, false), ([1], 2, false), ([1], [2], true))
140+
@test ArrayInterface.ismutable(ArrayPartition(a, b)) == r
141+
end

0 commit comments

Comments
 (0)