From 3c948494755c69279c92939fc1a54c3a3b26fe9a Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Sun, 26 May 2019 18:13:13 +0100 Subject: [PATCH 1/5] implement DataAPI --- src/PooledArrays.jl | 6 ++++++ test/runtests.jl | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/PooledArrays.jl b/src/PooledArrays.jl index 76ede45..5ab7c21 100644 --- a/src/PooledArrays.jl +++ b/src/PooledArrays.jl @@ -1,5 +1,7 @@ module PooledArrays +import DataAPI + export PooledArray, PooledVector, PooledMatrix ############################################################################## @@ -137,6 +139,10 @@ PooledArray(t::Type, r::Type) = PooledArray(Array(t,0), r) ## ############################################################################## +DataAPI.refarray(pa::PooledArray) = pa.refs +DataAPI.refvalue(pa::PooledArray, i) = pa.pool[i] +DataAPI.refpool(pa::PooledArray) = pa.pool + Base.size(pa::PooledArray) = size(pa.refs) Base.length(pa::PooledArray) = length(pa.refs) Base.lastindex(pa::PooledArray) = lastindex(pa.refs) diff --git a/test/runtests.jl b/test/runtests.jl index 1e25b5d..4687332 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,6 @@ using Test using PooledArrays +using DataAPI: refarray, refvalue, refpool let a = rand(10), b = rand(10,10), c = rand(1:10, 1000) @test PooledArray(a) == a @@ -68,4 +69,11 @@ let a = rand(10), b = rand(10,10), c = rand(1:10, 1000) @test eltype(PooledArray(rand(300)).refs) == UInt16 @test PooledVector == PooledArray{T, R, 1} where {T, R} @test PooledMatrix == PooledArray{T, R, 2} where {T, R} + + s = PooledArray(["a", "a", "b"]) + @test all(refarray(s) .== [1, 1, 2]) + for i in 1:3 + @test refvalue(s, refarray(s)[i]) == s[i] + end + @test refpool(s) == ["a", "b"] end From 26757d1e0d4980e0721784cca71e69eaab72c2d1 Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Thu, 19 Dec 2019 20:18:40 +0000 Subject: [PATCH 2/5] added DataAPI dependency --- Project.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Project.toml b/Project.toml index fca75a0..3e4c025 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,11 @@ name = "PooledArrays" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" version = "0.5.2" +[deps] +DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" + [compat] +DataAPI = "1" julia = "0.7, 1" [extras] From 029d7201954ebef858e93a2449617fa01157f2bf Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Thu, 19 Dec 2019 20:39:26 +0000 Subject: [PATCH 3/5] bump julia dep --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3e4c025..84e6890 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,7 @@ DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" [compat] DataAPI = "1" -julia = "0.7, 1" +julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From 0a61cf274de4260c2c77443fb5d9908076678648 Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Thu, 19 Dec 2019 23:12:52 +0000 Subject: [PATCH 4/5] remove julia pre 1 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f983d79..f703d29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ os: - osx julia: - - "0.7" - "1.0" - "1.1" - "nightly" From 3983a097d53d867e33d532c26df07be80f697e26 Mon Sep 17 00:00:00 2001 From: Pietro Vertechi Date: Fri, 20 Dec 2019 12:56:12 +0000 Subject: [PATCH 5/5] restrict refvalue signature --- src/PooledArrays.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PooledArrays.jl b/src/PooledArrays.jl index 5ab7c21..671649f 100644 --- a/src/PooledArrays.jl +++ b/src/PooledArrays.jl @@ -140,7 +140,7 @@ PooledArray(t::Type, r::Type) = PooledArray(Array(t,0), r) ############################################################################## DataAPI.refarray(pa::PooledArray) = pa.refs -DataAPI.refvalue(pa::PooledArray, i) = pa.pool[i] +DataAPI.refvalue(pa::PooledArray, i::Integer) = pa.pool[i] DataAPI.refpool(pa::PooledArray) = pa.pool Base.size(pa::PooledArray) = size(pa.refs)