Skip to content

Commit df232eb

Browse files
ismutable
1 parent 0f368ae commit df232eb

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
11
# ArrayInterface.jl
2-
Designs for new Base array interface primates
2+
3+
Julia has only recently reach v1.0 and the AbstractArray interface is still
4+
quite new. The purpose of this library is to solidify extensions to the current
5+
AbstractArray interface which are put to use in package ecosystems like
6+
DifferentialEquations.jl. Since these libraries are live, this package will
7+
serve as a staging ground for ideas before they merged into Base Julia. For this
8+
reason, no functionality is exported so that way if such functions are added
9+
and exported in a future Base Julia there will be no issues with the upgrade.
10+
11+
## ismutable(x)
12+
13+
A trait function for whether `x` is a mutable or immutable array. Used for
14+
dispatching to in-place and out-of-place versions of functions.
15+
16+
## List of things to add
17+
18+
https://github.com/JuliaLang/julia/issues/22216
19+
https://github.com/JuliaLang/julia/issues/22218
20+
https://github.com/JuliaLang/julia/issues/22622
21+
https://github.com/JuliaLang/julia/issues/25760
22+
https://github.com/JuliaLang/julia/issues/25107
23+
24+
## Array Types to Handle
25+
26+
The following common array types are being understood and tested as part of this
27+
development.
28+
29+
- Array
30+
- Various versions of sparse arrays
31+
- SArray (by having a separate implementation of each algorithm for immutables)
32+
- MArray (we have a workaround for this issue: never use out of place broadcast https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/pull/546)
33+
- FieldVector
34+
- ArrayPartition
35+
- VectorOfArray
36+
- DistributedArrays
37+
- GPUArrays (CLArrays and CuArrays)
38+
- AFArrays
39+
- MultiScaleArrays
40+
- LabelledArrays

src/ArrayInterface.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
module ArrayInterface
22

3+
using Requires
4+
5+
function ismutable end
6+
ismutable(x::Array) = true
7+
8+
9+
function __init__()
10+
11+
@require StaticArrays="90137ffa-7385-5640-81b9-e52037218182" begin
12+
ismutable(x::StaticArrays.StaticArray) = false
13+
ismutable(x::StaticArrays.MArray) = true
14+
end
15+
16+
@require LabelledArrays="2ee39098-c373-598a-b85f-a56591580800" begin
17+
ismutable(x::LVector) = ismutable(x.__x)
18+
end
19+
end
20+
321
end

test/REQUIRE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
StaticArrays
2+
LabelledArrays

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
using ArrayInterface, Test
12

3+
@test ArrayInterface.ismutable(rand(3))
4+
5+
using StaticArrays
6+
ArrayInterface.ismutable(@SVector [1,2,3]) == false
7+
ArrayInterface.ismutable(@MVector [1,2,3]) == true

0 commit comments

Comments
 (0)