From 6151b8e4730532c0b86a232e4cb731c1fa312717 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 8 Jul 2026 17:40:20 +0200 Subject: [PATCH] avoid depending on heavily invalidating pacakges These are not used in the package and should hence not be depended on --- Project.toml | 13 +++++++++---- ext/DataFramesSentinelArraysExt.jl | 22 ++++++++++++++++++++++ src/DataFrames.jl | 2 -- src/abstractdataframe/iteration.jl | 13 ------------- test/dataframe.jl | 7 ++++--- 5 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 ext/DataFramesSentinelArraysExt.jl diff --git a/Project.toml b/Project.toml index d55552669..298dedd34 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,6 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Future = "9fa8497b-333b-5362-9e8d-4d0656e87820" -InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" InvertedIndices = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -19,13 +18,18 @@ PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" TableTraits = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +[weakdeps] +SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" + +[extensions] +DataFramesSentinelArraysExt = "SentinelArrays" + [compat] CategoricalArrays = "0.10.0, 1" Combinatorics = "1.0.2" @@ -33,7 +37,6 @@ Compat = "4.2" DataAPI = "1.16.0" DataStructures = "0.18, 0.19" DataValues = "0.4.13" -InlineStrings = "1.3.0" InvertedIndices = "1.3" IteratorInterfaceExtensions = "0.1.1, 1" Missings = "0.4.2, 1" @@ -57,8 +60,10 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" DataValues = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" @@ -66,4 +71,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" [targets] -test = ["CategoricalArrays", "Combinatorics", "DataValues", "Dates", "Logging", "OffsetArrays", "ShiftedArrays", "SparseArrays", "StableRNGs", "Test", "Unitful"] +test = ["CategoricalArrays", "Combinatorics", "DataValues", "Dates", "InlineStrings", "Logging", "OffsetArrays", "SentinelArrays", "ShiftedArrays", "SparseArrays", "StableRNGs", "Test", "Unitful"] diff --git a/ext/DataFramesSentinelArraysExt.jl b/ext/DataFramesSentinelArraysExt.jl new file mode 100644 index 000000000..1c9ab97ef --- /dev/null +++ b/ext/DataFramesSentinelArraysExt.jl @@ -0,0 +1,22 @@ +module DataFramesSentinelArraysExt + +using DataFrames +using DataFrames: SymbolOrString +using SentinelArrays: ChainedVector + +# definition needed to avoid dispatch ambiguity between the `reduce(vcat, ...)` +# methods defined in DataFrames and the one defined in SentinelArrays for +# `ChainedVector` +Base.reduce(::typeof(vcat), + dfs::Union{ChainedVector{AbstractDataFrame,<:AbstractVector{AbstractDataFrame}}, + ChainedVector{DataFrame,<:AbstractVector{DataFrame}}, + ChainedVector{SubDataFrame,<:AbstractVector{SubDataFrame}}, + ChainedVector{Union{DataFrame,SubDataFrame},<:AbstractVector{Union{DataFrame,SubDataFrame}}}}; + cols::Union{Symbol,AbstractVector{Symbol}, + AbstractVector{<:AbstractString}}=:setequal, + source::Union{Nothing,SymbolOrString, + Pair{<:SymbolOrString,<:AbstractVector}}=nothing, + init::AbstractDataFrame=DataFrame()) = + reduce(vcat, collect(AbstractDataFrame, dfs), cols=cols, source=source, init=init) + +end # module diff --git a/src/DataFrames.jl b/src/DataFrames.jl index f4ce49ce3..15fe7a859 100644 --- a/src/DataFrames.jl +++ b/src/DataFrames.jl @@ -25,8 +25,6 @@ import Base.keepat!, Base.stack, LinearAlgebra.norm, PrecompileTools, - SentinelArrays, - InlineStrings, DataAPI, DataAPI.allcombinations, DataAPI.All, diff --git a/src/abstractdataframe/iteration.jl b/src/abstractdataframe/iteration.jl index 27034555a..8e213bde1 100644 --- a/src/abstractdataframe/iteration.jl +++ b/src/abstractdataframe/iteration.jl @@ -748,19 +748,6 @@ function Base.reduce(::typeof(vcat), return res end -# definition needed to avoid dispatch ambiguity -Base.reduce(::typeof(vcat), - dfs::Union{SentinelArrays.ChainedVector{AbstractDataFrame,<:AbstractVector{AbstractDataFrame}}, - SentinelArrays.ChainedVector{DataFrame,<:AbstractVector{DataFrame}}, - SentinelArrays.ChainedVector{SubDataFrame,<:AbstractVector{SubDataFrame}}, - SentinelArrays.ChainedVector{Union{DataFrame,SubDataFrame},<:AbstractVector{Union{DataFrame,SubDataFrame}}}}; - cols::Union{Symbol,AbstractVector{Symbol}, - AbstractVector{<:AbstractString}}=:setequal, - source::Union{Nothing,SymbolOrString, - Pair{<:SymbolOrString,<:AbstractVector}}=nothing, - init::AbstractDataFrame=DataFrame()) = - reduce(vcat, collect(AbstractDataFrame, dfs), cols=cols, source=source, init=init) - function _vcat(dfs::AbstractVector{AbstractDataFrame}; cols::Union{Symbol,AbstractVector{Symbol}, AbstractVector{<:AbstractString}}=:setequal) diff --git a/test/dataframe.jl b/test/dataframe.jl index 1d7753bf5..bf4549e43 100644 --- a/test/dataframe.jl +++ b/test/dataframe.jl @@ -1942,10 +1942,11 @@ end @test_throws ArgumentError reduce(vcat, dfs, cols=:union, source=:x, init=DataFrame(c=[1])) end -@testset "vcat ChainedVector ambiguity" begin - dfs = DataFrames.SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(a=2)]]) +import SentinelArrays +@testset "vcat ChainedVector" begin + dfs = SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(a=2)]]) @test reduce(vcat, dfs) == DataFrame(a=1:2) - dfs = DataFrames.SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(b=2)]]) + dfs = SentinelArrays.ChainedVector([[DataFrame(a=1)], [DataFrame(b=2)]]) @test reduce(vcat, dfs, cols=:union, source=:x, init=DataFrame(c=[])) ≅ DataFrame(c=missing, a=[1, missing], b=[missing, 2], x=1:2) end