From 0f39f5b088996da40290727744014405420f2953 Mon Sep 17 00:00:00 2001 From: Phillip Alday Date: Fri, 1 Oct 2021 13:28:37 +0000 Subject: [PATCH] ignore refpool type in intermediates for nlevlstbl (#56) * ignore refpool type in intermediates for nlevlstbl --- Project.toml | 2 +- src/utilities.jl | 6 ++++-- test/utilities.jl | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index ebd0bcb..c39306d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MixedModelsSim" uuid = "d5ae56c5-23ca-4a1f-b505-9fc4796fc1fe" authors = ["Phillip Alday", "Douglas Bates", "Lisa DeBruine", "Reinhold Kliegl"] -version = "0.2.5" +version = "0.2.6" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/utilities.jl b/src/utilities.jl index a1b6f23..5ef65f7 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -99,7 +99,9 @@ julia> nlevstbl(:item, 9, :level => ["low", "medium", "high"]) """ function nlevstbl(nm::Symbol, n::Integer, vars::Pair{Symbol, Vector{String}}...) nms = [nm] - vals = [PooledArray(nlevels(n, uppercase(first(string(nm)))), signed=true, compress=true)] + # need to specify PooledArray[] so that the array doesn't specialize on + # PooledArrays's type parameters + vals = PooledArray[PooledArray(nlevels(n, uppercase(first(string(nm)))); signed=true, compress=true)] inner = 1 for var in vars levs = last(var) @@ -107,7 +109,7 @@ function nlevstbl(nm::Symbol, n::Integer, vars::Pair{Symbol, Vector{String}}...) rept = inner * nlev q, r = divrem(n, rept) iszero(r) || throw(ArgumentError("n = $n is not a multiple of repetition block size $rept")) - push!(vals, PooledArray(repeat(levs, inner=inner, outer=q), signed=true, compress=true)) + push!(vals, PooledArray(repeat(levs, inner=inner, outer=q); signed=true, compress=true)) push!(nms, first(var)) inner = rept end diff --git a/test/utilities.jl b/test/utilities.jl index 3c6c9e3..c2304af 100644 --- a/test/utilities.jl +++ b/test/utilities.jl @@ -38,6 +38,11 @@ end @test length(twofac) == 3 @test length(first(twofac)) == 18 @test_throws ArgumentError nlevstbl(:item, 18, :level => ["low", "high"], :blur => ["N", "Y"]) + + item = nlevstbl(:subj, 128, :trt => ["C", "T"]) + @test item.subj isa PooledVector{String, Int16, Vector{Int16}} + @test item.trt isa PooledVector{String, Int8, Vector{Int8}} + @test length(item.subj) == length(item.trt) end @testset "pooled!" begin