diff --git a/CHANGELOG.md b/CHANGELOG.md index 542f9ab2..8f69c915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fix issue with `QuickSortAlg` in future version of Julia * Empty the rows of a `SubDataset` without columns +* Fix a bug which causes `modify/combine` throw errors on columns with Vector{Vector} type # Version 0.7.12 diff --git a/src/other/utils.jl b/src/other/utils.jl index 271c516d..dbe57112 100644 --- a/src/other/utils.jl +++ b/src/other/utils.jl @@ -30,10 +30,11 @@ end # modified return_type to suit for our purpose function return_type(f::Function, x) eltype(x) == Missing && return Missing - CT = nonmissingtype(eltype(x)) - if CT <: AbstractVector + + if eltype(x) <: AbstractVector return return_type_tuple(f, x) end + CT = nonmissingtype(eltype(x)) T = Core.Compiler.return_type(f, Tuple{Vector{CT}}) # workaround for SubArray type if T <: SubArray diff --git a/test/grouping.jl b/test/grouping.jl index dbdaa55b..9ca2ab82 100644 --- a/test/grouping.jl +++ b/test/grouping.jl @@ -642,3 +642,21 @@ end @test ds == Dataset(x1 = [1,2,1,2], x2 = [1,-2,-3,10], x3 = 1:4, z = [1.0, missing, -1.0, missing]) end + +@testset "combine and modify with Vector{Vector}" begin + ds = Dataset(x=[[1,2],[2,3]]) + @test modify(ds, :x=>length=>:y) == Dataset(x=[[1,2],[2,3]], y=2) + @test combine(ds, :x=>sum) == Dataset(sum_x=[3,5]) + + ds = Dataset(x=[[1.0,2.0,missing],[2.0,3.0,1.0]]) + @test modify(ds, :x=>length=>:y) == Dataset(x=[[1.0,2.0,missing],[2.0,3.0,1.0]], y=2) + @test combine(ds, :x=>(x->sum(x)::Vector{Union{Float64, Missing}})) == Dataset(function_x=[3.0,5.0,missing]) + + function _f_12345667(x, y) + map(z->z[1], x) .+ y + end + + ds = Dataset(x=[[1,2],[2,3]], y=2) + @test modify(ds, (:x,:y)=>_f_12345667) == Dataset(x=[[1,2],[2,3]], y=2,_f_12345667_x_y = [3,4]) + +end