Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SortedVector set type #38

Merged
merged 27 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/sortedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct SortedVector{T,V<:AbstractVector{T}} <: AbstractVector{T}
new{T,V}(sort(data))
end
end

function SortedVector{T,V}(x::Number) where {T,V<:AbstractVector{T}}
return new{T,V}(convert(V, [T(x)]))
end
gdalle marked this conversation as resolved.
Show resolved Hide resolved
end

Base.eltype(::SortedVector{T}) where {T} = T
Expand Down
6 changes: 6 additions & 0 deletions test/sortedvector.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using ADTypes
using SparseArrays
using SparseConnectivityTracer
using SparseConnectivityTracer: SortedVector
using Test
Expand All @@ -21,3 +23,7 @@ using Test
end
end
end;

sd = TracerSparsityDetector(SortedVector{UInt, Vector{UInt}})
@test ADTypes.jacobian_sparsity(diff, rand(10), sd) isa SparseMatrixCSC
@test_broken ADTypes.hessian_sparsity(x -> sum(abs2, diff(x)), rand(10), sd) isa SparseMatrixCSC
adrhill marked this conversation as resolved.
Show resolved Hide resolved
Loading