Skip to content

update to ArrayInterface v7 #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ authors = ["Chris Rackauckas <[email protected]>"]
version = "1.13.0"

[deps]
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
ArrayInterfaceStaticArrays = "b0d46f97-bff5-4637-a19a-dd75974142cd"
ArrayInterfaceStaticArraysCore = "dd5226c6-a4d4-4bc7-8575-46859f9c95b9"
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -16,9 +14,7 @@ PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"

[compat]
ArrayInterfaceCore = "0.1.22"
ArrayInterfaceStaticArrays = "0.1"
ArrayInterfaceStaticArraysCore = "0.1.3"
ArrayInterface = "7"
ChainRulesCore = "1"
ForwardDiff = "0.10.3"
MacroTools = "0.5"
Expand Down
12 changes: 6 additions & 6 deletions src/LabelledArrays.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LabelledArrays

using LinearAlgebra, StaticArrays, ArrayInterfaceCore
using LinearAlgebra, StaticArrays, ArrayInterface
import RecursiveArrayTools, PreallocationTools, ForwardDiff

include("slarray.jl")
Expand Down Expand Up @@ -59,14 +59,14 @@ end
Base.NamedTuple(x::Union{LArray, SLArray}) = NamedTuple{symnames(typeof(x))}(x.__x)
@inline Base.reshape(a::SLArray, s::Size) = StaticArrays.similar_type(a, s)(Tuple(a))

function ArrayInterfaceCore.ismutable(::Type{<:LArray{T, N, D, Syms}}) where {T, N, D, Syms}
ArrayInterfaceCore.ismutable(T)
function ArrayInterface.ismutable(::Type{<:LArray{T, N, D, Syms}}) where {T, N, D, Syms}
ArrayInterface.ismutable(T)
end
ArrayInterfaceCore.can_setindex(::Type{<:SLArray}) = false
ArrayInterface.can_setindex(::Type{<:SLArray}) = false

lenfun(x) = length(x)
lenfun(::Symbol) = 1
function ArrayInterfaceCore.undefmatrix(x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
function ArrayInterface.undefmatrix(x::LArray{T, N, D, Syms}) where {T, N, D, Syms}
n = sum(lenfun, Syms)
similar(x.__x, n, n)
end
Expand All @@ -78,7 +78,7 @@ function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache,
if nelem > length(dc.dual_du)
PreallocationTools.enlargedualcache!(dc, nelem)
end
_x = ArrayInterfaceCore.restructure(dc.du, reinterpret(T, view(dc.dual_du, 1:nelem)))
_x = ArrayInterface.restructure(dc.du, reinterpret(T, view(dc.dual_du, 1:nelem)))
LabelledArrays.LArray{T, N, D, Syms}(_x)
end

Expand Down
2 changes: 1 addition & 1 deletion src/larray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function Base.convert(::Type{AbstractArray{T, N}},
end
Base.convert(::Type{AbstractArray{T, N}}, x::LArray{T, N}) where {T, N} = x

function ArrayInterfaceCore.restructure(x::LArray{T, N, D, Syms},
function ArrayInterface.restructure(x::LArray{T, N, D, Syms},
y::LArray{T2, N2, D2, Syms}) where {T, N, D, T2, N2,
D2,
Syms}
Expand Down