From 3b4fcd8fac6a7df395144a4eb1037ca72f9fcaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Fri, 5 Apr 2024 23:09:13 +0200 Subject: [PATCH] disambiguate allunique signature (#3434) --- NEWS.md | 6 ++++++ src/abstractdataframe/unique.jl | 5 +++++ test/dataframe.jl | 1 + 3 files changed, 12 insertions(+) diff --git a/NEWS.md b/NEWS.md index 3b74a91e2..22d2045f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -37,6 +37,12 @@ release are now removed. ([#3422](/~https://github.com/JuliaData/DataFrames.jl/issues/3422)) +## Julia compatibility change + +* Ensure that `allunique(::AbstractDataFrame, ::Any)` always gets + interpreted as test for uniqueness of rows in the first positional argument + ([#3434](/~https://github.com/JuliaData/DataFrames.jl/issues/3434)) + # DataFrames.jl v1.6.1 Release Notes ## Bug fixes diff --git a/src/abstractdataframe/unique.jl b/src/abstractdataframe/unique.jl index 9441b825c..9e91d6a53 100644 --- a/src/abstractdataframe/unique.jl +++ b/src/abstractdataframe/unique.jl @@ -207,6 +207,11 @@ function Base.allunique(df::AbstractDataFrame, cols=:) Val(false), nothing, false, nothing, true)[1] == nrow(df) end +# avoid invoking Base.allunique(f, iterator) introduced in Julia 1.11 + +Base.allunique(df::AbstractDataFrame, cols::Tuple) = + invoke(Base.allunique, Tuple{AbstractDataFrame, Any}, df, cols) + """ unique(df::AbstractDataFrame; view::Bool=false, keep::Symbol=:first) unique(df::AbstractDataFrame, cols; view::Bool=false, keep::Symbol=:first) diff --git a/test/dataframe.jl b/test/dataframe.jl index 7efa1ca48..940590852 100644 --- a/test/dataframe.jl +++ b/test/dataframe.jl @@ -2331,6 +2331,7 @@ end @test allunique(df, []) @test allunique(df, x -> 1:4) @test allunique(df, [:a, :b] => ByRow(string)) + @test_throws ArgumentError allunique(df, ()) end end