Skip to content

Commit 7d9940d

Browse files
committed
add test to gatherby - bug #100
1 parent ff2015f commit 7d9940d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/grouping.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,15 @@ end
660660
@test modify(ds, (:x,:y)=>_f_12345667) == Dataset(x=[[1,2],[2,3]], y=2,_f_12345667_x_y = [3,4])
661661

662662
end
663+
664+
@testset "bug in gatheby with stable=true" begin
665+
x = string.([1,2,3,1,1,2,4,2,1])
666+
y = copy(x)
667+
frequency = [1000; fill(1, 8)]
668+
ds = Dataset(x=x, y=y, frequency=frequency)
669+
@test combine(gatherby(ds, 1:2, stable = true), 1 => first => :f) == Dataset(x = unique(x), y = unique(y), f = unique(x))
670+
@test combine(gatherby(ds, 1:2, stable = false), 1 => first => :f) == Dataset(x = string.([3,4,1,2]), y = string.([3,4,1,2]), f = string.([3,4,1,2]))
671+
repeat!(ds, freq=:frequency)
672+
@test combine(gatherby(ds, 1:2, stable = true), 1 => first => :f) == Dataset(x = unique(x), y = unique(y), f = unique(x))
673+
@test combine(gatherby(ds, 1:2, stable = false), 1 => first => :f) == Dataset(x = unique(x), y = unique(y), f = unique(x))
674+
end

0 commit comments

Comments
 (0)