Skip to content

Commit ab76ff8

Browse files
committed
Disallow negative values for nthreads
1 parent 3b5addb commit ab76ff8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/groupeddataframe/splitapplycombine.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ function _combine_prepare(gd::GroupedDataFrame,
2626
if !ungroup && !keepkeys
2727
throw(ArgumentError("keepkeys=false when ungroup=false is not allowed"))
2828
end
29+
if nthreads <= 0
30+
throw(ArgumentError("nthreads must be equal to or greater than 1 (got $nthreads)"))
31+
end
2932

3033
cs_vec = []
3134
for p in cs

test/grouping.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,4 +3299,12 @@ end
32993299
end
33003300
end
33013301

3302+
@testset "invalid nthreads" begin
3303+
gdf = groupby(DataFrame(x=1:10, y=1:10), :y)
3304+
@test_throws ArgumentError select(gdf, :x => sum, nthreads=0)
3305+
@test_throws ArgumentError transform(gdf, :x => sum, nthreads=0)
3306+
@test_throws ArgumentError select!(gdf, :x => sum, nthreads=0)
3307+
@test_throws ArgumentError transform!(gdf, :x => sum, nthreads=0)
3308+
end
3309+
33023310
end # module

0 commit comments

Comments
 (0)