From e91b15c79b55db1a85a13b488b8ec59fe37c46b3 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Tue, 21 May 2024 16:23:30 -0400 Subject: [PATCH 1/5] fix it? --- src/util/vectors.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/vectors.jl b/src/util/vectors.jl index 9eb588fa2..2d25e4b83 100644 --- a/src/util/vectors.jl +++ b/src/util/vectors.jl @@ -1,7 +1,7 @@ using Base: @propagate_inbounds -struct PlusOneVector{T} <: AbstractVector{T} - data::AbstractVector{T} +struct PlusOneVector{T, A <: AbstractVector{T}} <: AbstractVector{T} + data::A end @propagate_inbounds function Base.getindex(vec::PlusOneVector{T}, From a5647d59f066daa0ebc185f72273031c767692be Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Tue, 21 May 2024 16:28:42 -0400 Subject: [PATCH 2/5] oops --- src/util/vectors.jl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/util/vectors.jl b/src/util/vectors.jl index 2d25e4b83..65d350e08 100644 --- a/src/util/vectors.jl +++ b/src/util/vectors.jl @@ -4,6 +4,8 @@ struct PlusOneVector{T, A <: AbstractVector{T}} <: AbstractVector{T} data::A end +PlusOneVector(data::AbstractVector{T}) where {T} = PlusOneVector{T, typeof(data)}(data) + @propagate_inbounds function Base.getindex(vec::PlusOneVector{T}, index::Int) where {T} return vec.data[index] + 0x01 @@ -36,11 +38,11 @@ function moveto(vec::PlusOneVector{T}, device) where {T} return PlusOneVector{T}(data) end -struct MinusEpsVector{T, S} <: AbstractVector{T} - data::AbstractVector{S} +struct MinusEpsVector{T, S, A <: AbstractVector{S}} <: AbstractVector{T} + data::A end -MinusEpsVector(data::AbstractVector{T}) where {T} = MinusEpsVector{Limit{T}, T}(data) +MinusEpsVector(data::AbstractVector{T}) where {T} = MinusEpsVector{Limit{T}, T, typeof(data)}(data) @propagate_inbounds function Base.getindex(vec::MinusEpsVector{T}, index::Int) where {T} @@ -80,11 +82,11 @@ function moveto(vec::MinusEpsVector{T}, device) where {T} return MinusEpsVector{T}(data) end -struct PlusEpsVector{T, S} <: AbstractVector{T} - data::AbstractVector{S} +struct PlusEpsVector{T, S, A <:AbstractVector{S}} <: AbstractVector{T} + data::A end -PlusEpsVector(data::AbstractVector{T}) where {T} = PlusEpsVector{Limit{T}, T}(data) +PlusEpsVector(data::AbstractVector{T}) where {T} = PlusEpsVector{Limit{T}, T, typeof(data)}(data) @propagate_inbounds function Base.getindex(vec::PlusEpsVector{T}, index::Int) where {T} From 42219b961cc3326c9b5554dd19b0b63b9efb9a44 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Tue, 21 May 2024 16:29:00 -0400 Subject: [PATCH 3/5] fix --- src/util/vectors.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/vectors.jl b/src/util/vectors.jl index 65d350e08..a3c398a8f 100644 --- a/src/util/vectors.jl +++ b/src/util/vectors.jl @@ -4,8 +4,6 @@ struct PlusOneVector{T, A <: AbstractVector{T}} <: AbstractVector{T} data::A end -PlusOneVector(data::AbstractVector{T}) where {T} = PlusOneVector{T, typeof(data)}(data) - @propagate_inbounds function Base.getindex(vec::PlusOneVector{T}, index::Int) where {T} return vec.data[index] + 0x01 From 2095aa7acb6a32038c7b1d90bde2153961f99902 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Tue, 21 May 2024 16:39:24 -0400 Subject: [PATCH 4/5] fix --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index bd1e7c9e2..2d5a4ae26 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["Willow Ahrens"] name = "Finch" uuid = "9177782c-1635-4eb9-9bfb-d9dfa25e6bce" -version = "0.6.29" +version = "0.6.30" [compat] AbstractTrees = "0.3.4, 0.4" From daabc8a6360db8bf861818b4c75e90f823f868a2 Mon Sep 17 00:00:00 2001 From: Willow Ahrens Date: Tue, 21 May 2024 18:21:18 -0400 Subject: [PATCH 5/5] fix --- docs/src/guides/interoperability.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/src/guides/interoperability.md b/docs/src/guides/interoperability.md index 07705c603..7b95b1d00 100644 --- a/docs/src/guides/interoperability.md +++ b/docs/src/guides/interoperability.md @@ -30,26 +30,31 @@ julia> v = Vector([1, 0, 2, 3]) 0 2 3 + julia> obov = PlusOneVector(v) -4-element PlusOneVector{Int64}: +4-element PlusOneVector{Int64, Vector{Int64}}: 2 1 3 4 + julia> obov[1] += 8 10 + julia> obov -4-element PlusOneVector{Int64}: +4-element PlusOneVector{Int64, Vector{Int64}}: 10 1 3 4 + julia> obov.data 4-element Vector{Int64}: 9 0 2 3 + ``` ### `CIndex`