diff --git a/Project.toml b/Project.toml index 0c530b15..7280c0ee 100644 --- a/Project.toml +++ b/Project.toml @@ -1,18 +1,20 @@ name = "ComponentArrays" uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" authors = ["Jonnie Diegelman <47193959+jonniedie@users.noreply.github.com>"] -version = "0.13.7" +version = "0.13.8" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Requires = "ae029012-a4dd-5104-9daa-d747884805df" +StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718" [compat] ArrayInterface = "6, 7" ChainRulesCore = "0.8, 0.9, 0.10, 1" Requires = "1" +StaticArrayInterface = "1" julia = "1.6" [extras] diff --git a/src/ComponentArrays.jl b/src/ComponentArrays.jl index a88a7558..7777eeda 100644 --- a/src/ComponentArrays.jl +++ b/src/ComponentArrays.jl @@ -1,8 +1,7 @@ module ComponentArrays import ChainRulesCore -import ArrayInterface -import ArrayInterface.ArrayInterfaceCore +import StaticArrayInterface, ArrayInterface using LinearAlgebra using Requires @@ -27,11 +26,11 @@ export KeepIndex include("array_interface.jl") # Base methods: parent, size, elsize, axes, reinterpret, hcat, vcat, permutedims, IndexStyle, to_indices, to_index, getindex, setindex!, view, pointer, unsafe_convert, strides, stride -# ArrayInterface methods: strides, size, parent_type +# StaticArrayInterface methods: strides, size, parent_type include("linear_algebra.jl") # Base methods: *, \, / -# ArrayInterface methods: lu_instance +# StaticArrayInterface methods: lu_instance include("namedtuple_interface.jl") # Base methods: hash, ==, keys, haskey, propertynames, getproperty, setproperty! diff --git a/src/array_interface.jl b/src/array_interface.jl index 09c5439f..1fcbe631 100644 --- a/src/array_interface.jl +++ b/src/array_interface.jl @@ -1,7 +1,7 @@ Base.parent(x::ComponentArray) = getfield(x, :data) Base.size(x::ComponentArray) = size(getdata(x)) -ArrayInterface.size(A::ComponentArray) = ArrayInterface.size(parent(A)) +StaticArrayInterface.static_size(A::ComponentArray) = StaticArrayInterface.static_size(parent(A)) Base.elsize(x::Type{<:ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = Base.elsize(A) @@ -12,8 +12,8 @@ Base.reinterpret(::Type{T}, x::ComponentArray, args...) where T = ComponentArray Base.reshape(A::AbstractArray, axs::NTuple{N,<:CombinedAxis}) where {N} = reshape(A, _array_axis.(axs)) -ArrayInterfaceCore.indices_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterfaceCore.indices_do_not_alias(A) -ArrayInterfaceCore.instances_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterfaceCore.instances_do_not_alias(A) +ArrayInterface.indices_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterface.indices_do_not_alias(A) +ArrayInterface.instances_do_not_alias(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterface.instances_do_not_alias(A) # Cats # TODO: Make this a little less copy-pastey @@ -143,10 +143,10 @@ Base.unsafe_convert(::Type{Ptr{T}}, x::ComponentArray{T,N,A,Axes}) where {T,N,A, Base.strides(x::ComponentArray) = strides(getdata(x)) for f in [:device, :stride_rank, :contiguous_axis, :contiguous_batch_size, :dense_dims] - @eval ArrayInterface.$f(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = ArrayInterface.$f(A) + @eval StaticArrayInterface.$f(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = StaticArrayInterface.$f(A) end Base.stride(x::ComponentArray, k) = stride(getdata(x), k) Base.stride(x::ComponentArray, k::Int64) = stride(getdata(x), k) -ArrayInterfaceCore.parent_type(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = A \ No newline at end of file +ArrayInterface.parent_type(::Type{ComponentArray{T,N,A,Axes}}) where {T,N,A,Axes} = A \ No newline at end of file diff --git a/src/linear_algebra.jl b/src/linear_algebra.jl index 5d888e7f..52c7b456 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra.jl @@ -1,5 +1,5 @@ ## https://github.com/SciML/DifferentialEquations.jl/issues/849 -function ArrayInterfaceCore.lu_instance(x::ComponentMatrix) +function ArrayInterface.lu_instance(x::ComponentMatrix) T = eltype(x) noUnitT = typeof(zero(T)) luT = LinearAlgebra.lutype(noUnitT) diff --git a/test/runtests.jl b/test/runtests.jl index e47b4974..6ab1181f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -619,8 +619,8 @@ end @test convert(Cholesky{Float32,Matrix{Float32}}, chol).factors isa Matrix{Float32} # Issue #140 - @test ComponentArrays.ArrayInterfaceCore.indices_do_not_alias(typeof(ca)) == true - @test ComponentArrays.ArrayInterfaceCore.instances_do_not_alias(typeof(ca)) == false + @test ComponentArrays.ArrayInterface.indices_do_not_alias(typeof(ca)) == true + @test ComponentArrays.ArrayInterface.instances_do_not_alias(typeof(ca)) == false end @testset "Autodiff" begin