Skip to content
Open
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
52 changes: 26 additions & 26 deletions test/broadcasting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,10 @@ end

@testset "scalar on assignment side" begin
df = DataFrame(rand(2, 3), :auto)
@test_throws MethodError df[1, 1] .= df[1, 1] .- df[1, 1]
@test_throws Exception df[1, 1] .= df[1, 1] .- df[1, 1]
df[1, 1:1] .= df[1, 1] .- df[1, 1]
@test df[1, 1] == 0
@test_throws MethodError df[1, 2] .-= df[1, 2]
@test_throws Exception df[1, 2] .-= df[1, 2]
df[1:1, 2] .-= df[1, 2]
@test df[1, 2] == 0
end
Expand Down Expand Up @@ -1290,27 +1290,27 @@ end
@testset "additional checks of post-! broadcasting rules" begin
df = copy(refdf)
v1 = df[!, 1]
@test_throws MethodError df[CartesianIndex(1, 1)] .= 1
@test_throws MethodError df[CartesianIndex(1, 1)] .= "d"
@test_throws DimensionMismatch df[CartesianIndex(1, 1)] .= [1, 2]
@test_throws Exception df[CartesianIndex(1, 1)] .= 1
@test_throws Exception df[CartesianIndex(1, 1)] .= "d"
@test_throws Exception df[CartesianIndex(1, 1)] .= [1, 2]

df = copy(refdf)
v1 = df[!, 1]
@test_throws MethodError df[1, 1] .= 1
@test_throws MethodError df[1, 1] .= "d"
@test_throws DimensionMismatch df[1, 1] .= [1, 2]
@test_throws Exception df[1, 1] .= 1
@test_throws Exception df[1, 1] .= "d"
@test_throws Exception df[1, 1] .= [1, 2]

df = copy(refdf)
v1 = df[!, 1]
@test_throws MethodError df[1, :x1] .= 1
@test_throws MethodError df[1, :x1] .= "d"
@test_throws DimensionMismatch df[1, :x1] .= [1, 2]
@test_throws Exception df[1, :x1] .= 1
@test_throws Exception df[1, :x1] .= "d"
@test_throws Exception df[1, :x1] .= [1, 2]

df = copy(refdf)
v1 = df[!, 1]
@test_throws MethodError df[1, "x1"] .= 1
@test_throws MethodError df[1, "x1"] .= "d"
@test_throws DimensionMismatch df[1, "x1"] .= [1, 2]
@test_throws Exception df[1, "x1"] .= 1
@test_throws Exception df[1, "x1"] .= "d"
@test_throws Exception df[1, "x1"] .= [1, 2]

df = copy(refdf)
v1 = df[!, 1]
Expand Down Expand Up @@ -1485,21 +1485,21 @@ end

df = view(copy(refdf), :, :)
v1 = df[!, 1]
@test_throws MethodError df[CartesianIndex(1, 1)] .= 1
@test_throws MethodError df[CartesianIndex(1, 1)] .= "d"
@test_throws DimensionMismatch df[CartesianIndex(1, 1)] .= [1, 2]
@test_throws Exception df[CartesianIndex(1, 1)] .= 1
@test_throws Exception df[CartesianIndex(1, 1)] .= "d"
@test_throws Exception df[CartesianIndex(1, 1)] .= [1, 2]

df = view(copy(refdf), :, :)
v1 = df[!, 1]
@test_throws MethodError df[1, 1] .= 1
@test_throws MethodError df[1, 1] .= "d"
@test_throws DimensionMismatch df[1, 1] .= [1, 2]
@test_throws Exception df[1, 1] .= 1
@test_throws Exception df[1, 1] .= "d"
@test_throws Exception df[1, 1] .= [1, 2]

df = view(copy(refdf), :, :)
v1 = df[!, 1]
@test_throws MethodError df[1, :x1] .= 1
@test_throws MethodError df[1, :x1] .= "d"
@test_throws DimensionMismatch df[1, :x1] .= [1, 2]
@test_throws Exception df[1, :x1] .= 1
@test_throws Exception df[1, :x1] .= "d"
@test_throws Exception df[1, :x1] .= [1, 2]

df = view(copy(refdf), :, :)
v1 = df[!, 1]
Expand Down Expand Up @@ -1676,9 +1676,9 @@ end
@testset "add new correct rules for df[row, col] .= v broadcasting" begin
for v in [:a, "a"]
df = DataFrame(a=1)
@test_throws MethodError df[1, 1] .= 10
@test_throws MethodError df[1, v] .= 10
@test_throws MethodError df[CartesianIndex(1, 1)] .= 10
@test_throws Exception df[1, 1] .= 10
@test_throws Exception df[1, v] .= 10
@test_throws Exception df[CartesianIndex(1, 1)] .= 10
df = DataFrame(a=[[1, 2, 3]])
df[1, 1] .= 10
@test df == DataFrame(a=[[10, 10, 10]])
Expand Down
2 changes: 1 addition & 1 deletion test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ end
dfr[["a", "b"]] = (a=1000, b=2000)
@test copy(dfr) == (b=2000, a=1000)

@test_throws MethodError dfr["a"] .= 100
@test_throws Exception dfr["a"] .= 100
dfr[["a", "b"]] .= 50
@test copy(dfr) == (b=50, a=50)
end
Expand Down
Loading