Skip to content

Commit 3624839

Browse files
Drop StaticArrays by using StaticArraysCore
Requires JuliaArrays/ArrayInterface.jl#325 ```julia @time_imports using SciMLBase 10.4 ms ┌ MacroTools 19.0 ms ┌ ZygoteRules 3.8 ms ┌ Compat 1.5 ms ┌ Adapt 3.7 ms ┌ ArrayInterfaceCore 2.0 ms ┌ StaticArraysCore 9.7 ms ┌ ArrayInterfaceStaticArraysCore 123.1 ms ┌ FillArrays 5.0 ms ┌ DocStringExtensions 18.2 ms ┌ RecipesBase 51.3 ms ┌ ChainRulesCore 4.0 ms ┌ GPUArraysCore 292.7 ms RecursiveArrayTools ``` Compare that to #213
1 parent 945a9d1 commit 3624839

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Project.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ version = "2.30.0"
66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
9-
ArrayInterfaceStaticArrays = "b0d46f97-bff5-4637-a19a-dd75974142cd"
9+
ArrayInterfaceStaticArraysCore = "dd5226c6-a4d4-4bc7-8575-46859f9c95b9"
1010
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
1111
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1212
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
1313
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
16-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
16+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1717
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1818
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
1919

2020
[compat]
2121
Adapt = "3"
2222
ArrayInterfaceCore = "0.1.1"
23-
ArrayInterfaceStaticArrays = "0.1"
23+
ArrayInterfaceStaticArraysCore = "0.1"
2424
ChainRulesCore = "0.10.7, 1"
2525
DocStringExtensions = "0.8, 0.9"
2626
FillArrays = "0.11, 0.12, 0.13"
2727
GPUArraysCore = "0.1"
2828
RecipesBase = "0.7, 0.8, 1.0"
29-
StaticArrays = "0.12, 1.0"
29+
StaticArraysCore = "1"
3030
ZygoteRules = "0.2"
3131
julia = "1.6"
3232

@@ -36,10 +36,11 @@ NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
3636
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
3737
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3838
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
39+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
3940
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
4041
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4142
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
4243
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
4344

4445
[targets]
45-
test = ["ForwardDiff", "NLsolve", "OrdinaryDiffEq", "Pkg", "Test", "Unitful", "Random", "StructArrays", "Zygote"]
46+
test = ["ForwardDiff", "NLsolve", "OrdinaryDiffEq", "Pkg", "Test", "Unitful", "Random", "StaticArrays", "StructArrays", "Zygote"]

src/RecursiveArrayTools.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $(DocStringExtensions.README)
55
module RecursiveArrayTools
66

77
using DocStringExtensions
8-
using RecipesBase, StaticArrays, Statistics,
8+
using RecipesBase, StaticArraysCore, Statistics,
99
ArrayInterfaceCore, LinearAlgebra
1010

1111
import ChainRulesCore
@@ -15,7 +15,7 @@ import ZygoteRules, Adapt
1515
# Required for the downstream_events.jl test
1616
# Since `ismutable` on an ArrayPartition needs
1717
# to know static arrays are not mutable
18-
import ArrayInterfaceStaticArrays
18+
import ArrayInterfaceStaticArraysCore
1919

2020
using FillArrays
2121

src/utils.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ like `copy` on arrays of scalars.
99
function recursivecopy(a)
1010
deepcopy(a)
1111
end
12-
recursivecopy(a::Union{SVector,SMatrix,SArray,Number}) = copy(a)
12+
recursivecopy(a::Union{StaticArraysCore.SVector,StaticArraysCore.SMatrix,
13+
StaticArraysCore.SArray,Number}) = copy(a)
1314
function recursivecopy(a::AbstractArray{T,N}) where {T<:Number,N}
1415
copy(a)
1516
end
@@ -33,7 +34,7 @@ like `copy!` on arrays of scalars.
3334
"""
3435
function recursivecopy! end
3536

36-
function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:StaticArray,T2<:StaticArray,N}
37+
function recursivecopy!(b::AbstractArray{T,N},a::AbstractArray{T2,N}) where {T<:StaticArraysCore.StaticArray,T2<:StaticArraysCore.StaticArray,N}
3738
@inbounds for i in eachindex(a)
3839
# TODO: Check for `setindex!`` and use `copy!(b[i],a[i])` or `b[i] = a[i]`, see #19
3940
b[i] = copy(a[i])
@@ -68,13 +69,13 @@ A recursive `fill!` function.
6869
"""
6970
function recursivefill! end
7071

71-
function recursivefill!(b::AbstractArray{T,N},a::T2) where {T<:StaticArray,T2<:StaticArray,N}
72+
function recursivefill!(b::AbstractArray{T,N},a::T2) where {T<:StaticArraysCore.StaticArray,T2<:StaticArraysCore.StaticArray,N}
7273
@inbounds for i in eachindex(b)
7374
b[i] = copy(a)
7475
end
7576
end
7677

77-
function recursivefill!(b::AbstractArray{T,N},a::T2) where {T<:SArray,T2<:Union{Number,Bool},N}
78+
function recursivefill!(b::AbstractArray{T,N},a::T2) where {T<:StaticArraysCore.SArray,T2<:Union{Number,Bool},N}
7879
@inbounds for i in eachindex(b)
7980
b[i] = fill(a, typeof(b[i]))
8081
end
@@ -88,7 +89,7 @@ function recursivefill!(b::AbstractArray{T,N},a::T2) where {T<:Union{Number,Bool
8889
fill!(b, a)
8990
end
9091

91-
function recursivefill!(b::AbstractArray{T,N},a) where {T<:MArray,N}
92+
function recursivefill!(b::AbstractArray{T,N},a) where {T<:StaticArraysCore.MArray,N}
9293
@inbounds for i in eachindex(b)
9394
if isassigned(b,i)
9495
recursivefill!(b[i],a)
@@ -151,7 +152,7 @@ If `i<length(x)`, it's simply a `recursivecopy!` to the `i`th element. Otherwise
151152
function copyat_or_push!(a::AbstractVector{T},i::Int,x,nc::Type{Val{perform_copy}}=Val{true}) where {T,perform_copy}
152153
@inbounds if length(a) >= i
153154
if !ArrayInterfaceCore.ismutable(T) || !perform_copy
154-
# TODO: Check for `setindex!`` if T <: StaticArray and use `copy!(b[i],a[i])`
155+
# TODO: Check for `setindex!`` if T <: StaticArraysCore.StaticArray and use `copy!(b[i],a[i])`
155156
# or `b[i] = a[i]`, see https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19
156157
a[i] = x
157158
else
@@ -208,7 +209,7 @@ ones has a `Array{Array{Float64,N},N}`, this will return `Array{Float64,N}`.
208209
"""
209210
recursive_unitless_eltype(a) = recursive_unitless_eltype(eltype(a))
210211
recursive_unitless_eltype(a::Type{Any}) = Any
211-
recursive_unitless_eltype(a::Type{T}) where {T<:StaticArray} = similar_type(a,recursive_unitless_eltype(eltype(a)))
212+
recursive_unitless_eltype(a::Type{T}) where {T<:StaticArraysCore.StaticArray} = similar_type(a,recursive_unitless_eltype(eltype(a)))
212213
recursive_unitless_eltype(a::Type{T}) where {T<:Array} = Array{recursive_unitless_eltype(eltype(a)),ndims(a)}
213214
recursive_unitless_eltype(a::Type{T}) where {T<:Number} = typeof(one(eltype(a)))
214215
recursive_unitless_eltype(::Type{<:Enum{T}}) where T = T

0 commit comments

Comments
 (0)