diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4559a..1860802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Version `v0.6.8` * ![Feature][badge-feature] Support `clamp` and `clamp!` ([#208]) +* ![Maintenance][badge-maintenance] Remove internal set type `DuplicateVector` ([#209]) ## Version `v0.6.7` @@ -84,6 +85,7 @@ [badge-maintenance]: https://img.shields.io/badge/maintenance-gray.svg [badge-docs]: https://img.shields.io/badge/docs-orange.svg +[#209]: https://github.com/adrhill/SparseConnectivityTracer.jl/pull/209 [#208]: https://github.com/adrhill/SparseConnectivityTracer.jl/pull/208 [#205]: https://github.com/adrhill/SparseConnectivityTracer.jl/pull/205 [#204]: https://github.com/adrhill/SparseConnectivityTracer.jl/pull/204 diff --git a/src/SparseConnectivityTracer.jl b/src/SparseConnectivityTracer.jl index 8ecd652..bfa4701 100644 --- a/src/SparseConnectivityTracer.jl +++ b/src/SparseConnectivityTracer.jl @@ -11,7 +11,6 @@ using FillArrays: Fill using DocStringExtensions: DocStringExtensions, TYPEDEF, TYPEDFIELDS -include("settypes/duplicatevector.jl") include("settypes/recursiveset.jl") include("settypes/sortedvector.jl") diff --git a/src/patterns.jl b/src/patterns.jl index 5bb02b1..7a1ec1b 100644 --- a/src/patterns.jl +++ b/src/patterns.jl @@ -117,7 +117,7 @@ function union_product!( end # Some custom set types don't support `push!` -for S in (:DuplicateVector, :SortedVector, :RecursiveSet) +for S in (:SortedVector, :RecursiveSet) @eval function union_product!( hessian::$S{Tuple{I,I}}, gradient_x::$S{I}, gradient_y::$S{I} ) where {I<:Integer} diff --git a/src/settypes/duplicatevector.jl b/src/settypes/duplicatevector.jl deleted file mode 100644 index c334ed1..0000000 --- a/src/settypes/duplicatevector.jl +++ /dev/null @@ -1,42 +0,0 @@ -""" - DuplicateVector - -Vector that can have duplicate values, for which union is just concatenation. -""" -struct DuplicateVector{T} <: AbstractSet{T} - data::Vector{T} - - DuplicateVector{T}(data::AbstractVector) where {T} = new{T}(convert(Vector{T}, data)) - DuplicateVector{T}(x) where {T} = new{T}([convert(T, x)]) - DuplicateVector{T}() where {T} = new{T}(T[]) -end - -Base.show(io::IO, dv::DuplicateVector) = print(io, "DuplicateVector($(dv.data))") - -function Base.show(io::IO, ::MIME"text/plain", dv::DuplicateVector) - return print(io, "DuplicateVector($(dv.data))") -end - -Base.eltype(::Type{DuplicateVector{T}}) where {T} = T -Base.length(dv::DuplicateVector) = length(collect(dv)) # TODO: slow -Base.copy(dv::DuplicateVector{T}) where {T} = DuplicateVector{T}(dv.data) - -function Base.union!(a::S, b::S) where {S<:DuplicateVector} - append!(a.data, b.data) - return a -end - -function Base.union(a::S, b::S) where {S<:DuplicateVector} - return S(vcat(a.data, b.data)) -end - -Base.collect(dv::DuplicateVector) = unique!(dv.data) - -Base.iterate(dv::DuplicateVector) = iterate(collect(dv)) -Base.iterate(dv::DuplicateVector, i::Integer) = iterate(collect(dv), i) - -function product(a::DuplicateVector{T}, b::DuplicateVector{T}) where {T} - return DuplicateVector{Tuple{T,T}}( - vec(collect((i, j) for i in a.data, j in b.data if i <= j)) - ) -end diff --git a/test/brusselator.jl b/test/brusselator.jl index 7b1597e..8f726d2 100644 --- a/test/brusselator.jl +++ b/test/brusselator.jl @@ -2,7 +2,6 @@ using ADTypes using ADTypes: AbstractSparsityDetector using ReferenceTests using SparseConnectivityTracer -using SparseConnectivityTracer: DuplicateVector, RecursiveSet, SortedVector using SparseConnectivityTracerBenchmarks.ODE: Brusselator! using Test diff --git a/test/flux.jl b/test/flux.jl index afdb1d9..5ea643b 100644 --- a/test/flux.jl +++ b/test/flux.jl @@ -3,7 +3,6 @@ using ADTypes: AbstractSparsityDetector using Flux: Conv, relu using ReferenceTests using SparseConnectivityTracer -using SparseConnectivityTracer: DuplicateVector, RecursiveSet, SortedVector using Test # Load definitions of GRADIENT_TRACERS, GRADIENT_PATTERNS, HESSIAN_TRACERS and HESSIAN_PATTERNS diff --git a/test/settypes/correctness.jl b/test/settypes/correctness.jl index 11a8288..35f61bb 100644 --- a/test/settypes/correctness.jl +++ b/test/settypes/correctness.jl @@ -1,10 +1,8 @@ using SparseConnectivityTracer -using SparseConnectivityTracer: DuplicateVector, RecursiveSet, SortedVector, product +using SparseConnectivityTracer: RecursiveSet, SortedVector, product using Test -@testset "$S" for S in ( - BitSet, Set{Int}, DuplicateVector{Int}, RecursiveSet{Int}, SortedVector{Int} -) +@testset "$S" for S in (BitSet, Set{Int}, RecursiveSet{Int}, SortedVector{Int}) x = S.(1:10) y = (x[1] ∪ x[3]) ∪ (x[3] ∪ ((x[5] ∪ x[7]) ∪ x[1])) diff --git a/test/tracers_definitions.jl b/test/tracers_definitions.jl index f7d6803..f770422 100644 --- a/test/tracers_definitions.jl +++ b/test/tracers_definitions.jl @@ -1,13 +1,12 @@ using SparseConnectivityTracer: AbstractTracer, GradientTracer, HessianTracer, Dual using SparseConnectivityTracer: IndexSetGradientPattern using SparseConnectivityTracer: IndexSetHessianPattern, DictHessianPattern -using SparseConnectivityTracer: DuplicateVector, RecursiveSet, SortedVector +using SparseConnectivityTracer: RecursiveSet, SortedVector using SparseConnectivityTracer: Shared, NotShared GRADIENT_PATTERNS = ( IndexSetGradientPattern{Int,BitSet}, IndexSetGradientPattern{Int,Set{Int}}, - IndexSetGradientPattern{Int,DuplicateVector{Int}}, IndexSetGradientPattern{Int,SortedVector{Int}}, IndexSetGradientPattern{Int,RecursiveSet{Int}}, ) @@ -19,9 +18,6 @@ HESSIAN_PATTERNS_SHARED = ( HESSIAN_PATTERNS_NOTSHARED = ( IndexSetHessianPattern{Int,BitSet,Set{Tuple{Int,Int}},NotShared}, IndexSetHessianPattern{Int,BitSet,Set{Tuple{Int,Int}},NotShared}, - IndexSetHessianPattern{ - Int,DuplicateVector{Int},DuplicateVector{Tuple{Int,Int}},NotShared - }, IndexSetHessianPattern{Int,SortedVector{Int},SortedVector{Tuple{Int,Int}},NotShared}, # TODO: test on RecursiveSet DictHessianPattern{Int,BitSet,Dict{Int,BitSet},NotShared},