Skip to content

Commit b1acd86

Browse files
committed
fix the problem with Julia nightly - return_type
1 parent c72762a commit b1acd86

File tree

10 files changed

+32
-33
lines changed

10 files changed

+32
-33
lines changed

src/abstractdataset/abstractdataset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ end
147147
function _check_format_validity(ds, col, f)
148148
flag = false
149149
string(nameof(f))[1] == '#' && return flag
150-
Core.Compiler.return_type(f, (eltype(ds[!, col].val), )) == Union{} && return flag
150+
Core.Compiler.return_type(f, Tuple{eltype(ds[!, col].val)}) == Union{} && return flag
151151
flag = true
152152
end
153153
#Modify Dataset

src/byrow/byrow.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ function byrow(ds::AbstractDataset, f::Function, cols::MultiColumnIndex; threads
154154
end
155155
function byrow(ds::AbstractDataset, f::Function, col::ColumnIndex; threads = nrow(ds)>1000)
156156
if threads
157-
T = Core.Compiler.return_type(f, (nonmissingtype(eltype(ds[!, col])), ))
157+
T = Core.Compiler.return_type(f, Tuple{nonmissingtype(eltype(ds[!, col]))})
158158
res = Vector{Union{Missing, T}}(undef, nrow(ds))
159159
_hp_map_a_function!(res, f, _columns(ds)[index(ds)[col]])
160160
else
161-
T = Core.Compiler.return_type(f, (nonmissingtype(eltype(ds[!, col])), ))
161+
T = Core.Compiler.return_type(f, Tuple{nonmissingtype(eltype(ds[!, col]))})
162162
res = Vector{Union{Missing, T}}(undef, nrow(ds))
163163
map!(f, res, _columns(ds)[index(ds)[col]])
164164
end

src/byrow/row_functions.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
function row_sum(ds::AbstractDataset, f::Function, cols = names(ds, Union{Missing, Number}); threads = true)
3535
colsidx = multiple_getindex(index(ds), cols)
3636
CT = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
37-
T = Core.Compiler.return_type(f, (CT,))
37+
T = Core.Compiler.return_type(f, Tuple{CT})
3838
init0 = _missings(T, nrow(ds))
3939

4040
if threads
@@ -64,7 +64,7 @@ end
6464
function row_prod(ds::AbstractDataset, f::Function, cols = names(ds, Union{Missing, Number}); threads = true)
6565
colsidx = multiple_getindex(index(ds), cols)
6666
CT = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
67-
T = Core.Compiler.return_type(f, (CT,))
67+
T = Core.Compiler.return_type(f, Tuple{CT})
6868
init0 = _missings(T, nrow(ds))
6969

7070
if threads
@@ -568,7 +568,7 @@ end
568568
function row_minimum(ds::AbstractDataset, f::Function, cols = names(ds, Union{Missing, Number}); threads = true)
569569
colsidx = multiple_getindex(index(ds), cols)
570570
CT = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
571-
T = Core.Compiler.return_type(f, (CT,))
571+
T = Core.Compiler.return_type(f, Tuple{CT})
572572
init0 = _missings(T, nrow(ds))
573573

574574
if threads
@@ -588,7 +588,7 @@ row_minimum(ds::AbstractDataset, cols = names(ds, Union{Missing, Number}); threa
588588
function row_maximum(ds::AbstractDataset, f::Function, cols = names(ds, Union{Missing, Number}); threads = true)
589589
colsidx = multiple_getindex(index(ds), cols)
590590
CT = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
591-
T = Core.Compiler.return_type(f, (CT,))
591+
T = Core.Compiler.return_type(f, Tuple{CT})
592592
init0 = _missings(T, nrow(ds))
593593

594594
if threads
@@ -691,12 +691,12 @@ end
691691
function row_var(ds::AbstractDataset, f::Function, cols = names(ds, Union{Missing, Number}); dof = true, threads = true)
692692
colsidx = multiple_getindex(index(ds), cols)
693693
CT = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
694-
T = Core.Compiler.return_type(f, (CT,))
694+
T = Core.Compiler.return_type(f, Tuple{CT})
695695
_sq_(x) = x^2
696696
ss = row_sum(ds, _sq_ f, cols; threads = threads)
697697
sval = row_sum(ds, f, cols; threads = threads)
698698
n = row_count(ds, x -> !ismissing(x), cols; threads = threads)
699-
T2 = Core.Compiler.return_type(/, (eltype(ss), eltype(n)))
699+
T2 = Core.Compiler.return_type(/, Tuple{eltype(ss), eltype(n)})
700700
res = Vector{Union{Missing, T2}}(undef, length(ss))
701701
res .= ss ./ n .- (sval ./ n) .^ 2
702702
if dof

src/dataset/other.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ function Base.map(ds::AbstractDataset, f::Vector{<:Function}, cols::MultiColumnI
394394
v = _columns(ds)[j]
395395

396396
if threads
397-
T = Core.Compiler.return_type(_f, (eltype(v), ))
397+
T = Core.Compiler.return_type(_f, Tuple{eltype(v)})
398398
fv = _our_vect_alloc(T, length(v))
399399
_hp_map_a_function!(fv, _f, v)
400400
else
@@ -492,7 +492,7 @@ function Base.map!(ds::AbstractDataset, f::Vector{<:Function}, cols::MultiColumn
492492
# Core.Compiler.return_type cannot handle the situations like x->ismissing(x) ? 0 : x when x is missing and float, since the output of Core.Compiler.return_type is Union{Missing, Float64, Int64}
493493
# we remove missing and then check the result,
494494
# TODO is there any problem with this?
495-
T = Core.Compiler.return_type(f[j], (nonmissingtype(CT),))
495+
T = Core.Compiler.return_type(f[j], Tuple{nonmissingtype(CT)})
496496
T = Union{Missing, T}
497497
if promote_type(T, CT) <: CT
498498
if threads && DataAPI.refpool(_columns(ds)[colsidx[j]]) === nothing

src/join/closejoin.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ function _change_refpool_find_range_for_close!(ranges, dsl, dsr, r_perms, oncols
290290
_fr = identity
291291
end
292292

293-
T1 = Core.Compiler.return_type(_fl, (eltype(var_l), ))
293+
T1 = Core.Compiler.return_type(_fl, Tuple{eltype(var_l)})
294294

295295
if DataAPI.refpool(var_r) !== nothing && nsfpaj
296296
true && throw(ErrorException("we shouldn't end up here"))
297297
else
298-
T2 = Core.Compiler.return_type(_fr, (eltype(var_r), ))
298+
T2 = Core.Compiler.return_type(_fr, Tuple{eltype(var_r)})
299299
if direction == :backward
300300
_find_ranges_for_closeback!(ranges, var_l, view(var_r, r_perms), _fl, _fr, Val(T1), Val(T2); threads = threads)
301301
elseif direction == :forward

src/join/join.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function _change_refpool_find_range_for_join!(ranges, dsl, dsr, r_perms, oncols_
373373
_fr = identity
374374
end
375375

376-
T1 = Core.Compiler.return_type(DataAPI.unwrap_fl, (eltype(var_l), ))
376+
T1 = Core.Compiler.return_type(DataAPI.unwrap_fl, Tuple{eltype(var_l)})
377377

378378
if DataAPI.refpool(var_r) !== nothing && nsfpaj
379379
# sort taken care for refs ordering of modified values, but we still need to change refs
@@ -388,7 +388,7 @@ function _change_refpool_find_range_for_join!(ranges, dsl, dsr, r_perms, oncols_
388388
# we should use invpool of right column
389389
_find_ranges_for_join_pa!(ranges, var_l, DataAPI.invrefpool(var_r_cpy), view(DataAPI.refarray(var_r_cpy), r_perms), _fl, _fr, Val(T1), Val(T2); type = type, threads = threads)
390390
else
391-
T2 = Core.Compiler.return_type(_fr, (eltype(var_r), ))
391+
T2 = Core.Compiler.return_type(_fr, Tuple{eltype(var_r)})
392392
_find_ranges_for_join!(ranges, var_l, view(var_r, r_perms), _fl, _fr, Val(T1), Val(T2); type = type, threads = threads)
393393
end
394394
end

src/other/utils.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ function return_type(f::Function, x)
3434
if CT <: AbstractVector
3535
return return_type_tuple(f, x)
3636
end
37-
T = Core.Compiler.return_type(f, (Vector{CT}, ))
37+
T = Core.Compiler.return_type(f, Tuple{Vector{CT}})
3838
# workaround for SubArray type
3939
if T <: SubArray
40-
return Core.Compiler.return_type(f, (typeof(x), ))
40+
return Core.Compiler.return_type(f, Tuple{typeof(x)})
4141
elseif T <: AbstractVector
4242
T = AbstractVector{Union{Missing, eltype(T)}}
4343
elseif T <: Tuple
44-
T = Union{Missing, Core.Compiler.return_type(f, (Vector{eltype(x)}, ))}
44+
T = Union{Missing, Core.Compiler.return_type(f, Tuple{Vector{eltype(x)}})}
4545
else
4646
T = Union{Missing, T}
4747
end
@@ -50,14 +50,14 @@ end
5050

5151
function return_type_tuple(f::Function, x)
5252
CT = ntuple(i -> nonmissingtype(eltype(x[i])), length(x))
53-
T = Core.Compiler.return_type(f, ntuple(i->Vector{CT[i]}, length(x)))
53+
T = Core.Compiler.return_type(f, Tuple{ntuple(i->Vector{CT[i]}, length(x))...})
5454
# workaround for SubArray type
5555
if T <: SubArray
56-
return Core.Compiler.return_type(f, typeof.(x))
56+
return Core.Compiler.return_type(f, Tuple{(typeof.(x))...})
5757
elseif T <: AbstractVector
5858
T = AbstractVector{Union{Missing, eltype(T)}}
5959
elseif T <: Tuple
60-
T = Union{Missing, Core.Compiler.return_type(f, ntuple(i->Vector{eltype(x[i])}, length(x)))}
60+
T = Union{Missing, Core.Compiler.return_type(f, Tuple{ntuple(i->Vector{eltype(x[i])}, length(x))...})}
6161
else
6262
T = Union{Missing, T}
6363
end
@@ -436,7 +436,7 @@ function _gather_groups(ds, cols, ::Val{T}; mapformats = false, stable = true, t
436436
else
437437
v = _columns(ds)[colidx[j]]
438438
end
439-
if nonmissingtype(Core.Compiler.return_type(_f, (nonmissingtype(eltype(v)),))) <: Union{Missing, INTEGERS}
439+
if nonmissingtype(Core.Compiler.return_type(_f, Tuple{nonmissingtype(eltype(v))})) <: Union{Missing, INTEGERS}
440440
if threads
441441
_minval = hp_minimum(_f, v)
442442
else
@@ -741,7 +741,7 @@ struct Cat2Vec{F1, F2, CT, T, S, A, B} <: AbstractVector{Union{T, S}}
741741
_rev_map_invrefpool!(res, dict, x, f1)
742742
new{typeof(identity), typeof(identity), Union{Missing, vtype}, Union{vtype, Missing}, Union{vtype, Missing}, typeof(res), typeof(res)}(res, DataAPI.refarray(v), identity, identity, length(x), length(y))
743743
else
744-
new{F1, F2, promote_type(Core.Compiler.return_type(f1, (eltype(x), )), Core.Compiler.return_type(f2, (eltype(y), ))), eltype(x), eltype(y), typeof(x), typeof(y)}(x, y, f1, f2, length(x), length(y))
744+
new{F1, F2, promote_type(Core.Compiler.return_type(f1, Tuple{eltype(x)}), Core.Compiler.return_type(f2, Tuple{eltype(y)})), eltype(x), eltype(y), typeof(x), typeof(y)}(x, y, f1, f2, length(x), length(y))
745745
end
746746
else
747747
if DataAPI.invrefpool(y) !== nothing
@@ -775,12 +775,11 @@ struct Cat2Vec{F1, F2, CT, T, S, A, B} <: AbstractVector{Union{T, S}}
775775
_rev_map_invrefpool!(res, dict, y, f2)
776776
new{typeof(identity), typeof(identity), Union{Missing ,vtype}, Union{vtype, Missing}, Union{vtype, Missing}, typeof(res), typeof(res)}(DataAPI.refarray(v), res, identity, identity, length(x), length(y))
777777
else
778-
new{F1, F2, promote_type(Core.Compiler.return_type(f1, (eltype(x), )), Core.Compiler.return_type(f2, (eltype(y), ))), eltype(x), eltype(y), typeof(x), typeof(y)}(x, y, f1, f2, length(x), length(y))
778+
new{F1, F2, promote_type(Core.Compiler.return_type(f1, Tuple{eltype(x)}), Core.Compiler.return_type(f2, Tuple{eltype(y)})), eltype(x), eltype(y), typeof(x), typeof(y)}(x, y, f1, f2, length(x), length(y))
779779
end
780780
end
781781
end
782-
#
783-
# Cat2Vec(x,y,f1::F1,f2::F2) where {F1, F2}= new{F1, F2, promote_type(Core.Compiler.return_type(f1, (eltype(x), )), Core.Compiler.return_type(f2, (eltype(y), ))), eltype(x), eltype(y), typeof(x), typeof(y)}(x, y, f1, f2, length(x), length(y))
782+
784783
end
785784

786785
function _rev_map_invrefpool!(res, dict, y, f)

src/sort/gatherby.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ end
166166

167167
_gatherby_maximum(gds, col; f = identity, nt = Threads.nthreads(), threads = true) = gatherby_mapreduce(gds, f, _stat_max_fun, col, nt, missing, Val(nonmissingtype(eltype(gds.parent[!, col]))), threads = threads)
168168
_gatherby_minimum(gds, col; f = identity, nt = Threads.nthreads(), threads = true) = gatherby_mapreduce(gds, f, _stat_min_fun, col, nt, missing, Val(nonmissingtype(eltype(gds.parent[!, col]))), threads = threads)
169-
_gatherby_sum(gds, col; f = identity, nt = Threads.nthreads(), threads = true) = gatherby_mapreduce(gds, f, _stat_add_sum, col, nt, missing, Val(typeof(zero(Core.Compiler.return_type(f, (eltype(gds.parent[!, col]), ))))), promotetypes = true, threads = threads)
169+
_gatherby_sum(gds, col; f = identity, nt = Threads.nthreads(), threads = true) = gatherby_mapreduce(gds, f, _stat_add_sum, col, nt, missing, Val(typeof(zero(Core.Compiler.return_type(f, Tuple{eltype(gds.parent[!, col])})))), promotetypes = true, threads = threads)
170170
_gatherby_n(gds, col; nt = Threads.nthreads(), threads = true) = _gatherby_sum(gds, col, f = _stat_notmissing, nt = nt, threads = threads)
171171
_gatherby_length(gds, col; nt = Threads.nthreads(), threads = true) = _gatherby_sum(gds, col, f = x->1, nt = nt, threads = threads)
172172
_gatherby_cntnan(gds, col; nt = Threads.nthreads(), threads = true) = _gatherby_sum(gds, col, f = ISNAN, nt = nt, threads = threads)
@@ -199,7 +199,7 @@ function _gatherby_mean(gds, col; nt = Threads.nthreads(), threads = true)
199199
nval = t2
200200
end
201201

202-
T = Core.Compiler.return_type(/, (nonmissingtype(eltype(sval)), nonmissingtype(eltype(nval))))
202+
T = Core.Compiler.return_type(/, Tuple{nonmissingtype(eltype(sval)), nonmissingtype(eltype(nval))})
203203
res = _our_vect_alloc(Union{Missing, T}, length(nval))
204204
_fill_gatherby_mean_barrier!(res, sval, nval)
205205
res
@@ -255,7 +255,7 @@ function _gatherby_var(gds, col; dof = true, cal_std = false, threads = true)
255255
ss = t3
256256
nval = t4
257257
end
258-
T = Core.Compiler.return_type(/, (nonmissingtype(eltype(meanval)), nonmissingtype(eltype(nval))))
258+
T = Core.Compiler.return_type(/, Tuple{nonmissingtype(eltype(meanval)), nonmissingtype(eltype(nval))})
259259
res = _our_vect_alloc(Union{Missing, T}, length(nval))
260260
_fill_gatherby_var_barrier!(res, countnan, meanval, ss, nval, cal_std, dof)
261261
res

src/sort/sortperm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ end
133133
function _apply_by_f_barrier(x::AbstractVector{T}, by, rev, threads) where T
134134
needrev = rev
135135
missat = :right
136-
CT = Core.Compiler.return_type(_date_valueby, (nonmissingtype(T), ))
136+
CT = Core.Compiler.return_type(_date_valueby, Tuple{nonmissingtype(T)})
137137
if CT == Bool
138138
CT = Int8
139139
end

src/stat/hp_stat.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function hp_maximum(f, x::AbstractVector{T}) where T
33
nt = Threads.nthreads()
44
cz = div(n, nt)
55
cz == 0 && return stat_maximum(f, x)
6-
CT = Core.Compiler.return_type(f, (nonmissingtype(eltype(x)), ))
6+
CT = Core.Compiler.return_type(f, Tuple{nonmissingtype(eltype(x))})
77
if T >: Missing
88
CT = Union{Missing, CT}
99
end
@@ -22,7 +22,7 @@ function hp_minimum(f, x::AbstractVector{T}) where T
2222
nt = Threads.nthreads()
2323
cz = div(n, nt)
2424
cz == 0 && return stat_minimum(f, x)
25-
CT = Core.Compiler.return_type(f, (nonmissingtype(eltype(x)), ))
25+
CT = Core.Compiler.return_type(f, Tuple{nonmissingtype(eltype(x))})
2626
if T >: Missing
2727
CT = Union{Missing, CT}
2828
end
@@ -41,7 +41,7 @@ function hp_sum(f, x::AbstractVector{T}) where T
4141
nt = Threads.nthreads()
4242
cz = div(n, nt)
4343
cz == 0 && return stat_sum(f, x)
44-
CT = Core.Compiler.return_type(f, (nonmissingtype(eltype(x)), ))
44+
CT = Core.Compiler.return_type(f, Tuple{nonmissingtype(eltype(x))})
4545
CT <: Base.SmallSigned ? CT = Int : nothing
4646
CT <: Base.SmallUnsigned ? CT = UInt : nothing
4747
CT <: Bool ? CT = Int : nothing

0 commit comments

Comments
 (0)