diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml index 717f01ec..05422f43 100644 --- a/.github/workflows/Documenter.yml +++ b/.github/workflows/Documenter.yml @@ -12,9 +12,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-docdeploy@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} with: - version: '1.5' + version: '1.6' - name: Install dependencies run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: Build and deploy diff --git a/NEWS.md b/NEWS.md index 21bae0fe..c7226574 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# DataFramesMeta v0.9.1 Release notes + +* Fix a bug with `@rtransform!` and `@rselect!`, where the macros were not actually mutating the data frame. ([#294](https://github.com/JuliaData/DataFramesMeta.jl/pull/294)) + # DataFramesMeta v0.9.0 Release notes * Add `@passmissing` flag for skipping missing values in row-wise macros. ([#272](https://github.com/JuliaData/DataFramesMeta.jl/pull/272)) diff --git a/Project.toml b/Project.toml index 8b7621db..fbb357d4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DataFramesMeta" uuid = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" -version = "0.9.0" +version = "0.9.1" [deps] Chain = "8be319e6-bccf-4806-a6f7-6fae938471bc" diff --git a/docs/Project.toml b/docs/Project.toml index 261fa6f4..61cf4177 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" diff --git a/src/macros.jl b/src/macros.jl index 4e30d93e..d9f2b85e 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -1272,7 +1272,7 @@ end Row-wise version of `@transform!`, i.e. all operations use `@byrow` by default. See [`@transform!`](@ref) for details.""" macro rtransform!(x, args...) - esc(rtransform_helper(x, args...)) + esc(rtransform!_helper(x, args...)) end ############################################################################## @@ -1521,7 +1521,7 @@ function rselect!_helper(x, args...) t = (fun_to_vec(ex; gensym_names=false, outer_flags=outer_flags) for ex in exprs) quote - $DataFrames.select($x, $(t...)) + $DataFrames.select!($x, $(t...)) end end @@ -1532,7 +1532,7 @@ Row-wise version of `@select!`, i.e. all operations use `@byrow` by default. See [`@select!`](@ref) for details. """ macro rselect!(x, args...) - esc(rselect_helper(x, args...)) + esc(rselect!_helper(x, args...)) end ############################################################################## diff --git a/test/byrow.jl b/test/byrow.jl index 1e611e7b..de721de1 100644 --- a/test/byrow.jl +++ b/test/byrow.jl @@ -163,17 +163,21 @@ end @test @rtransform!(copy(df), :n = :g == 1 && :t == "a") ≅ @transform!(copy(df), :n = map((g, t) -> g == 1 && t == "a", :g, :t)) @test @rtransform!(copy(df), :n = first(:g)) ≅ @transform!(copy(df), :n = first.(:g)) - d = @rtransform! df begin + df2 = copy(df) + d = @rtransform! df2 begin :n1 = :i :n2 = :i * :g end + @test d === df2 @test d ≅ @transform!(copy(df), :n1 = :i, :n2 = :i .* :g) @test d ≅ @transform!(copy(df), @byrow(:n1 = :i), @byrow(:n2 = :i * :g)) - d = @rtransform! df begin + df2 = copy(df) + d = @rtransform! df2 begin cols(:n1) = :i :n2 = cols(:i) * :g end + @test d === df2 @test d ≅ @transform!(copy(df), :n1 = :i, :n2 = :i .* :g) d = @rtransform! df begin :n1 = cols(:i) @@ -352,17 +356,21 @@ end @test @rselect!(copy(df), :n = :g == 1 && :t == "a") ≅ @select!(copy(df), :n = map((g, t) -> g == 1 && t == "a", :g, :t)) @test @rselect!(copy(df), :n = first(:g)) ≅ @select!(copy(df), :n = first.(:g)) - d = @rselect! copy(df) begin + df2 = copy(df) + d = @rselect! df2 begin :n1 = :i :n2 = :i * :g end + @test d === df2 @test d ≅ @select!(copy(df), :n1 = :i, :n2 = :i .* :g) @test d ≅ @select!(copy(df), @byrow(:n1 = :i), @byrow(:n2 = :i * :g)) - d = @rselect! copy(df) begin + df2 = copy(df) + d = @rselect! df2 begin cols(:n1) = :i :n2 = cols(:i) * :g end + @test d === df2 @test d ≅ @select!(copy(df), :n1 = :i, :n2 = :i .* :g) d = @rselect! copy(df) begin :n1 = cols(:i) @@ -437,10 +445,12 @@ end @testset "@subset! with @byrow" begin df = DataFrame(A = [1, 2, 3, missing], B = [2, 1, 2, 1]) - d = @subset! copy(df) begin + df2 = copy(df) + d = @subset! df2 begin @byrow :A > 1 @byrow :B > 1 end + @test d === df2 @test d ≅ @subset(df, :A .> 1, :B .> 1) d = @subset! copy(df) @byrow begin @@ -453,10 +463,12 @@ end @testset "@rsubset!" begin df = DataFrame(A = [1, 2, 3, missing], B = [2, 1, 2, 1]) - d = @rsubset! copy(df) begin + df2 = copy(df) + d = @rsubset! df2 begin :A > 1 :B > 1 end + @test d === df2 @test d ≅ @subset(df, :A .> 1, :B .> 1) d = @rsubset! copy(df) begin @@ -633,4 +645,18 @@ end # no `@orderby!` for some reason. end +@testset "row operations modify" begin + df = DataFrame(a = 1, b = 2) + cols = ["a", "b"] + for c in cols + @rtransform! df $c = $c + 100 + end + + @test df == DataFrame(a = 101, b = 102) + + df = DataFrame(a = 1, b = 2) + @rselect! df :x = :a + @test names(df) == ["x"] +end + end \ No newline at end of file