Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions src/other/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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