Skip to content

Commit 91032bc

Browse files
committed
correct test
1 parent 06c8314 commit 91032bc

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/GroupedArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ DataAPI.refvalue(g::GroupedArray, ref::Integer) = ref > 0 ? ref : missing
5555
struct GroupedRefPool{T <: Union{Int, Missing}} <: AbstractVector{T}
5656
ngroups::Int
5757
end
58-
Base.size(x::GroupedRefPool{T}) where T = (x.ngroups + T >: Missing,)
58+
Base.size(x::GroupedRefPool{T}) where T = (x.ngroups + (T >: Missing),)
5959
Base.axes(x::GroupedRefPool{T}) where T = ((1-(T >: Missing)):x.ngroups,)
6060
Base.IndexStyle(::Type{<: GroupedRefPool}) = Base.IndexLinear()
6161
Base.@propagate_inbounds function Base.getindex(x::GroupedRefPool{T}, i::Integer) where T

test/runtests.jl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ g1 = GroupedArray(p1_missing; coalesce = true)
5151

5252
p2 = repeat(1:5, outer = 2)
5353
g = GroupedArray(p1_missing, p2)
54-
@test g[1] === missing
54+
@test ismissing(g[1])
5555
g[3] = missing
56-
@test g[3] === missing
56+
@test ismissing(g[3])
5757

5858
p3 = [1,2]
5959
@test_throws DimensionMismatch GroupedArray(p1, p3)
@@ -64,30 +64,41 @@ g = GroupedArray(p)
6464

6565
using CategoricalArrays
6666
g = GroupedArray(categorical(p1_missing), categorical(p2))
67-
@test g[1] === missing
67+
@test ismissing(g[1])
6868

6969
using PooledArrays
7070
g = GroupedArray(PooledArray(p1_missing), PooledArray(p2))
71-
@test g[1] === missing
71+
@test ismissing(g[1])
7272

73-
g = GroupedArray(PooledArray(p1_missing), p2)
74-
@test g[1] === missing
7573

7674

7775
using DataAPI
76+
g = GroupedArray(PooledArray(p1_missing), p2)
77+
@test g[1] === missing
7878
refs = DataAPI.refarray(g)
7979
pools = DataAPI.refpool(g)
8080
invrefpools = DataAPI.invrefpool(g)
8181
@test all(pools[refs] .=== g)
8282
@test all(DataAPI.refvalue(g, refs[i]) === g[i] for i in 1:length(g))
83-
83+
@test allunique(pools)
84+
@test size(pools) == (8,)
8485
for x in eachindex(pools)
8586
@test invrefpools[pools[x]] == x
8687
end
87-
@test get(invrefpools, missing, -1) == -1
88+
@test get(invrefpools, missing, -1) == 0
8889

89-
pools[invrefpools[missing]] == missing
90+
@test ismissing(pools[invrefpools[missing]])
9091
for ix in 1:g.ngroups
9192
pools[invrefpools[ix]] == ix
9293
end
9394

95+
g = GroupedArray(p2)
96+
invrefpools = DataAPI.invrefpool(g)
97+
@test get(invrefpools, missing, -1) == -1
98+
99+
100+
101+
102+
103+
104+

0 commit comments

Comments
 (0)