From cef762e78a6a9ec902d72e591517808b1228fbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Koren?= Date: Fri, 26 Jul 2024 17:55:40 +0200 Subject: [PATCH] bugfix: double vectorization in replace - fixes #182 - new test added - 405/405 tests pass - version bumped to 0.5.1 --- Project.toml | 2 +- src/commands.jl | 2 +- test/commands.jl | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 15406e8..b29eec1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Kezdi" uuid = "48308a23-c29e-446c-b4c0-d9446a767439" authors = ["Miklos Koren ", "Gergely Attila Kiss "] -version = "0.5.0" +version = "0.5.1" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/src/commands.jl b/src/commands.jl index faac0f8..abaf4f5 100644 --- a/src/commands.jl +++ b/src/commands.jl @@ -31,7 +31,7 @@ function rewrite(::Val{:replace}, command::Command) target_column = get_LHS(command.arguments[1]) LHS, RHS = split_assignment(arguments[1]) third_vector = gensym() - bitmask = build_bitmask(local_copy, vectorize_function_calls(replace_column_references(local_copy, command.condition))) + bitmask = build_bitmask(local_copy, command.condition) quote !($target_column in names(getdf())) && ArgumentError("Column \"$($target_column)\" does not exist in $(names(getdf()))") |> throw $setup diff --git a/test/commands.jl b/test/commands.jl index de7517a..b100762 100644 --- a/test/commands.jl +++ b/test/commands.jl @@ -112,6 +112,11 @@ end @testset "Error handling" begin @test_throws Exception @with df @replace y = 1 end + + @testset "Double vectorization bug (#182)" begin + positive(x) = x > 0 + @test (@with DataFrame(x=1:4, y=5:8) @replace y = 0 @if positive(x - 2)).y == [5, 6, 0, 0] + end end @testset "Missing values" begin