Skip to content

Commit 0f39f5b

Browse files
authored
ignore refpool type in intermediates for nlevlstbl (#56)
* ignore refpool type in intermediates for nlevlstbl
1 parent 500eaa9 commit 0f39f5b

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MixedModelsSim"
22
uuid = "d5ae56c5-23ca-4a1f-b505-9fc4796fc1fe"
33
authors = ["Phillip Alday", "Douglas Bates", "Lisa DeBruine", "Reinhold Kliegl"]
4-
version = "0.2.5"
4+
version = "0.2.6"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/utilities.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,17 @@ julia> nlevstbl(:item, 9, :level => ["low", "medium", "high"])
9999
"""
100100
function nlevstbl(nm::Symbol, n::Integer, vars::Pair{Symbol, Vector{String}}...)
101101
nms = [nm]
102-
vals = [PooledArray(nlevels(n, uppercase(first(string(nm)))), signed=true, compress=true)]
102+
# need to specify PooledArray[] so that the array doesn't specialize on
103+
# PooledArrays's type parameters
104+
vals = PooledArray[PooledArray(nlevels(n, uppercase(first(string(nm)))); signed=true, compress=true)]
103105
inner = 1
104106
for var in vars
105107
levs = last(var)
106108
nlev = length(levs)
107109
rept = inner * nlev
108110
q, r = divrem(n, rept)
109111
iszero(r) || throw(ArgumentError("n = $n is not a multiple of repetition block size $rept"))
110-
push!(vals, PooledArray(repeat(levs, inner=inner, outer=q), signed=true, compress=true))
112+
push!(vals, PooledArray(repeat(levs, inner=inner, outer=q); signed=true, compress=true))
111113
push!(nms, first(var))
112114
inner = rept
113115
end

test/utilities.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ end
3838
@test length(twofac) == 3
3939
@test length(first(twofac)) == 18
4040
@test_throws ArgumentError nlevstbl(:item, 18, :level => ["low", "high"], :blur => ["N", "Y"])
41+
42+
item = nlevstbl(:subj, 128, :trt => ["C", "T"])
43+
@test item.subj isa PooledVector{String, Int16, Vector{Int16}}
44+
@test item.trt isa PooledVector{String, Int8, Vector{Int8}}
45+
@test length(item.subj) == length(item.trt)
4146
end
4247

4348
@testset "pooled!" begin

0 commit comments

Comments
 (0)