From a387caec0aee5e37e99eeb714e9a2ae7e6c14e65 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Thu, 11 Aug 2022 10:14:19 +0000 Subject: [PATCH] use ArrayInterfaceCore for fast using time --- Project.toml | 4 ++-- src/DimensionalData.jl | 2 +- src/array/array.jl | 2 +- test/array.jl | 6 +----- test/ecosystem.jl | 9 ++++++++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index ece34121f..c050a6445 100644 --- a/Project.toml +++ b/Project.toml @@ -5,7 +5,7 @@ version = "0.20.11" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910" @@ -19,7 +19,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] Adapt = "2, 3.0" -ArrayInterface = "3.1, 4, 5, 6" +ArrayInterfaceCore = "0.1" ConstructionBase = "1" Extents = "0.1" IntervalSets = "0.5, 0.6, 0.7" diff --git a/src/DimensionalData.jl b/src/DimensionalData.jl index 48ad108c0..524235518 100644 --- a/src/DimensionalData.jl +++ b/src/DimensionalData.jl @@ -21,7 +21,7 @@ using Base: tail, OneTo, @propagate_inbounds # Ecosystem import Adapt, - ArrayInterface, + ArrayInterfaceCore, ConstructionBase, Extents, RecipesBase, diff --git a/src/array/array.jl b/src/array/array.jl index bae83bfb5..00a584c5f 100644 --- a/src/array/array.jl +++ b/src/array/array.jl @@ -170,7 +170,7 @@ for (d, s) in ((:AbstractDimArray, :AbstractDimArray), end Base.copy!(dst::SparseArrays.SparseVector, src::AbstractDimArray{T,1}) where T = copy!(dst, parent(src)) -ArrayInterface.parent_type(::Type{<:AbstractDimArray{T,N,D,A}}) where {T,N,D,A} = A +ArrayInterfaceCore.parent_type(::Type{<:AbstractDimArray{T,N,D,A}}) where {T,N,D,A} = A function Adapt.adapt_structure(to, A::AbstractDimArray) rebuild(A, diff --git a/test/array.jl b/test/array.jl index 6e7523499..3f0065155 100644 --- a/test/array.jl +++ b/test/array.jl @@ -1,4 +1,4 @@ -using DimensionalData, Test, Unitful, SparseArrays, Dates, Random, ArrayInterface +using DimensionalData, Test, Unitful, SparseArrays, Dates, Random using DimensionalData: layerdims using DimensionalData.LookupArrays, DimensionalData.Dimensions @@ -343,7 +343,3 @@ end da3 = DimArray(a2, dimz2; refdims=refdimz, name=DimensionalData.Name(:test3)) @test NamedTuple(da, da3) == (; test=da, test3=da3) end - -@testset "ArrayInterface" begin - @test ArrayInterface.parent_type(da) == Matrix{Int} -end diff --git a/test/ecosystem.jl b/test/ecosystem.jl index 78cf74c63..9b1de3094 100644 --- a/test/ecosystem.jl +++ b/test/ecosystem.jl @@ -1,4 +1,11 @@ -using OffsetArrays, ImageFiltering, ImageTransformations, DimensionalData +using OffsetArrays, ImageFiltering, ImageTransformations, ArrayInterfaceCore, DimensionalData, Test + +@testset "ArrayInterface" begin + a = [1 2; 3 4] + dimz = X(143.0:2.0:145.0), Y(-38.0:2.0:-36.0) + da = DimArray(a, dimz) + @test ArrayInterfaceCore.parent_type(typeof(da)) == Matrix{Int} +end @testset "OffsetArray" begin a = [1 2 3 4