926926 DataFrame (x1= Char[], a= Int[])
927927 end
928928 @test_throws ArgumentError select (df, [] => (() -> [9 ]) => :a , :)
929- @test_throws ArgumentError select (df, :, [] => (() -> [9 ]) => :a )
929+ @test_throws DimensionMismatch select (df, :, [] => (() -> [9 ]) => :a )
930930 @test transform (df, names (df) .=> (x -> 9 ) .=> names (df)) ==
931931 repeat (DataFrame ([9 9 9 ], :auto ), nrow (df))
932932 @test combine (df, names (df) .=> (x -> 9 ) .=> names (df)) ==
@@ -1012,15 +1012,15 @@ end
10121012 @test df2. x4_last isa CategoricalVector{Int}
10131013 end
10141014
1015- @test_throws ArgumentError select (df, names (df) .=> first, [] => (() -> Int[]) => :x1 )
1015+ @test_throws DimensionMismatch select (df, names (df) .=> first, [] => (() -> Int[]) => :x1 )
10161016 df2 = combine (df, names (df) .=> first, [] => (() -> Int[]) => :x1 )
10171017 @test size (df2) == (0 , 5 )
10181018 @test df2. x1_first isa Vector{Int}
10191019 @test df2. x2_first isa CategoricalVector{Int}
10201020 @test df2. x3_first isa Vector{Missing}
10211021 @test df2. x4_first isa Vector{Missing}
10221022
1023- @test_throws ArgumentError select (df, names (df) .=> last, [] => (() -> Int[]) => :x1 )
1023+ @test_throws DimensionMismatch select (df, names (df) .=> last, [] => (() -> Int[]) => :x1 )
10241024 df2 = combine (df, names (df) .=> last, [] => (() -> Int[]) => :x1 )
10251025 @test size (df2) == (0 , 5 )
10261026 @test df2. x1_last isa Vector{Int}
@@ -1274,8 +1274,8 @@ end
12741274 @test df2. y === df. y
12751275 @test transform (df, names (df) .=> first .=> names (df)) ==
12761276 DataFrame (x= fill (1 , 3 ), y= fill (4 , 3 ))
1277- @test_throws ArgumentError transform (df, :x => x -> [first (x)], copycols= true )
1278- @test_throws ArgumentError transform (df, :x => x -> [first (x)], copycols= false )
1277+ @test_throws DimensionMismatch transform (df, :x => x -> [first (x)], copycols= true )
1278+ @test_throws DimensionMismatch transform (df, :x => x -> [first (x)], copycols= false )
12791279
12801280 dfv = view (df, [2 , 1 ], [2 , 1 ])
12811281 @test select (dfv, :x => first) == DataFrame (x_first= fill (2 , 2 ))
@@ -1293,8 +1293,8 @@ end
12931293 @test_throws ArgumentError transform (dfv, :x => first, copycols= false )
12941294 @test transform (dfv, names (dfv) .=> first .=> names (dfv)) ==
12951295 DataFrame (y= fill (5 , 2 ), x= fill (2 , 2 ))
1296- @test_throws ArgumentError transform (df, :x => x -> [first (x)], copycols= true )
1297- @test_throws ArgumentError transform (df, :x => x -> [first (x)], copycols= false )
1296+ @test_throws DimensionMismatch transform (df, :x => x -> [first (x)], copycols= true )
1297+ @test_throws DimensionMismatch transform (df, :x => x -> [first (x)], copycols= false )
12981298end
12991299
13001300@testset " select! and transform! AbstractDataFrame" begin
@@ -1328,7 +1328,7 @@ end
13281328 @test df == DataFrame (x= fill (1 , 3 ), y= fill (4 , 3 ))
13291329
13301330 df = DataFrame (x= 1 : 3 , y= 4 : 6 )
1331- @test_throws ArgumentError transform! (df, :x => x -> [1 ])
1331+ @test_throws DimensionMismatch transform! (df, :x => x -> [1 ])
13321332 @test df == DataFrame (x= 1 : 3 , y= 4 : 6 )
13331333
13341334 dfv = view (df, [2 , 1 ], [2 , 1 ])
@@ -1388,7 +1388,7 @@ end
13881388 @test transform (sdf -> sdf. b, df) == [df DataFrame (x1= 3 : 4 )]
13891389 @test transform (sdf -> (b = 2 sdf. b,), df) == DataFrame (a= 1 : 2 , b= [6 , 8 ], c= 5 : 6 )
13901390 @test transform (sdf -> (b = 1 ,), df) == DataFrame (a= [1 , 2 ], b= [1 , 1 ], c= [5 , 6 ])
1391- @test_throws ArgumentError transform (sdf -> (b = [1 ],), df)
1391+ @test_throws DimensionMismatch transform (sdf -> (b = [1 ],), df)
13921392 @test transform (sdf -> (b = [1 , 5 ],), df) == DataFrame (a= [1 , 2 ], b= [1 , 5 ], c= [5 , 6 ])
13931393 @test transform (sdf -> 1 , df) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= 1 )
13941394 @test transform (sdf -> fill ([1 ]), df) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= [[1 ], [1 ]])
@@ -1398,8 +1398,8 @@ end
13981398 for ret in (DataFrame (), NamedTuple (), zeros (0 , 0 ), DataFrame (t= 1 )[1 , 1 : 0 ])
13991399 @test transform (sdf -> ret, df) == df
14001400 end
1401- @test_throws ArgumentError transform (sdf -> DataFrame (a= 10 ), df)
1402- @test_throws ArgumentError transform (sdf -> zeros (1 , 2 ), df)
1401+ @test_throws DimensionMismatch transform (sdf -> DataFrame (a= 10 ), df)
1402+ @test_throws DimensionMismatch transform (sdf -> zeros (1 , 2 ), df)
14031403 @test transform (sdf -> DataFrame (a= [10 , 11 ]), df) == DataFrame (a= [10 , 11 ], b= 3 : 4 , c= 5 : 6 )
14041404 @test transform (sdf -> [10 11 ; 12 13 ], df) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= [10 , 12 ], x2= [11 , 13 ])
14051405 @test transform (sdf -> DataFrame (a= 10 )[1 , :], df) == DataFrame (a= [10 , 10 ], b= 3 : 4 , c= 5 : 6 )
@@ -1447,7 +1447,7 @@ end
14471447 @test transform! (sdf -> sdf. b, copy (df)) == [df DataFrame (x1= 3 : 4 )]
14481448 @test transform! (sdf -> (b = 2 sdf. b,), copy (df)) == DataFrame (a= 1 : 2 , b= [6 , 8 ], c= 5 : 6 )
14491449 @test transform! (sdf -> (b = 1 ,), copy (df)) == DataFrame (a= [1 , 2 ], b= [1 , 1 ], c= [5 , 6 ])
1450- @test_throws ArgumentError transform! (sdf -> (b = [1 ],), copy (df))
1450+ @test_throws DimensionMismatch transform! (sdf -> (b = [1 ],), copy (df))
14511451 @test transform! (sdf -> (b = [1 , 5 ],), copy (df)) == DataFrame (a= [1 , 2 ], b= [1 , 5 ], c= [5 , 6 ])
14521452 @test transform! (sdf -> 1 , copy (df)) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= 1 )
14531453 @test transform! (sdf -> fill ([1 ]), copy (df)) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= [[1 ], [1 ]])
@@ -1457,8 +1457,8 @@ end
14571457 for ret in (DataFrame (), NamedTuple (), zeros (0 , 0 ), DataFrame (t= 1 )[1 , 1 : 0 ])
14581458 @test transform! (sdf -> ret, copy (df)) == df
14591459 end
1460- @test_throws ArgumentError transform! (sdf -> DataFrame (a= 10 ), copy (df))
1461- @test_throws ArgumentError transform! (sdf -> zeros (1 , 2 ), copy (df))
1460+ @test_throws DimensionMismatch transform! (sdf -> DataFrame (a= 10 ), copy (df))
1461+ @test_throws DimensionMismatch transform! (sdf -> zeros (1 , 2 ), copy (df))
14621462 @test transform! (sdf -> DataFrame (a= [10 , 11 ]), copy (df)) == DataFrame (a= [10 , 11 ], b= 3 : 4 , c= 5 : 6 )
14631463 @test transform! (sdf -> [10 11 ; 12 13 ], copy (df)) == DataFrame (a= 1 : 2 , b= 3 : 4 , c= 5 : 6 , x1= [10 , 12 ], x2= [11 , 13 ])
14641464 @test transform! (sdf -> DataFrame (a= 10 )[1 , :], copy (df)) == DataFrame (a= [10 , 10 ], b= 3 : 4 , c= 5 : 6 )
@@ -1490,7 +1490,7 @@ end
14901490 @test combine (df, :a => (x -> res) => [:p , :q ]) == DataFrame (p= 1 , q= 2 )
14911491 @test_throws ArgumentError combine (df, :a => (x -> res) => [:p ])
14921492 @test_throws ArgumentError select (df, :a => (x -> res) => AsTable)
1493- @test_throws ArgumentError transform (df, :a => (x -> res) => AsTable)
1493+ @test_throws DimensionMismatch transform (df, :a => (x -> res) => AsTable)
14941494 end
14951495 @test combine (df, :a => ByRow (x -> [x, x+ 1 ]),
14961496 :a => ByRow (x -> [x, x+ 1 ]) => AsTable,
@@ -1626,8 +1626,8 @@ end
16261626 DataFrame (a1= 1 , a2= 2 , a= 1 : 2 )
16271627 @test select (df, :a => (x -> 1 ) => :a1 , :a => (x -> 2 ) => :a2 , [:a ]) ==
16281628 DataFrame (a1= 1 , a2= 2 , a= 1 : 2 )
1629- @test_throws ArgumentError combine (df, :a => (x -> 1 ) => :a1 , :a => (x -> [2 ]) => :a2 , [:a ])
1630- @test_throws ArgumentError select (df, :a => (x -> 1 ) => :a1 , :a => (x -> [2 ]) => :a2 , [:a ])
1629+ @test_throws DimensionMismatch combine (df, :a => (x -> 1 ) => :a1 , :a => (x -> [2 ]) => :a2 , [:a ])
1630+ @test_throws DimensionMismatch select (df, :a => (x -> 1 ) => :a1 , :a => (x -> [2 ]) => :a2 , [:a ])
16311631end
16321632
16331633@testset " normalize_selection" begin
0 commit comments