Closed terasakisatoshi closed 9 months ago
Should I update @testset "matrix"
in runtests.jl
? If so, here is my suggestion:
diff --git a/src/CircularArrays.jl b/src/CircularArrays.jl
index c6036f5..a08cce9 100644
--- a/src/CircularArrays.jl
+++ b/src/CircularArrays.jl
@@ -3,7 +3,7 @@ Arrays with fixed size and circular indexing.
"""
module CircularArrays
-export CircularArray, CircularVector
+export CircularArray, CircularVector, CircularMatrix
"""
CircularArray{T, N, A} <: AbstractArray{T, N}
@@ -106,6 +106,13 @@ Create a `CircularVector` wrapping the array `data`.
"""
CircularVector(data::AbstractArray{T, 1}) where T = CircularVector{T}(data)
+"""
+ CircularMatrix(data)
+
+Create a `CircularMatrix` wrapping the array `data`.
+"""
+CircularMatrix(data::AbstractArray{T, 2}) where T = CircularMatrix{T}(data)
+
"""
CircularVector(def, size)
@@ -113,6 +120,13 @@ Create a `CircularVector` of size `size` filled with value `def`.
"""
CircularVector(def::T, size::Int) where T = CircularVector{T}(fill(def, size))
+"""
+ CircularMatrix(def, size)
+
+Create a `CircularMatrix` of size `size` filled with value `def`.
+"""
+CircularMatrix(def::T, size::NTuple{2, Integer}) where T = CircularMatrix{T}(fill(def, size))
+
Base.empty(::CircularVector{T}, ::Type{U}=T) where {T,U} = CircularVector{U}(U[])
function Base.deleteat!(a::CircularVector, i::Integer)
diff --git a/test/runtests.jl b/test/runtests.jl
index 4102294..baa1632 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -150,7 +150,7 @@ end
@testset "matrix" begin
b_arr = [2 4 6 8; 10 12 14 16; 18 20 22 24]
- a1 = CircularArray(b_arr)
+ a1 = CircularMatrix(b_arr)
@test size(a1) == (3, 4)
@test parent(a1) == b_arr
@@ -179,21 +179,25 @@ end
@test !isa(a1, CircularVector)
@test !isa(a1, AbstractVector)
+ @test isa(a1, AbstractMatrix)
@test isa(a1, AbstractArray)
@test size(reshape(a1, (2, 2, 3))) == (2, 2, 3)
- a2 = CircularArray(4, (2, 3))
+ a2 = CircularMatrix(4, (2, 3))
+ @test isa(a2, CircularMatrix{Int})
@test isa(a2, CircularArray{Int, 2})
a3 = @inferred(a2 .+ 1)
+ @test a3 isa CircularMatrix{Int64}
@test a3 isa CircularArray{Int64, 2}
@test a3 == CircularArray(5, (2, 3))
@testset "doubly circular" begin
- a = CircularArray(b_arr)
- da = CircularArray(a)
+ a = CircularMatrix(b_arr)
+ da = CircularMatrix(a)
+ @test da isa CircularMatrix
@test all(a[i, j] == da[i, j] for i in -8:8, j in -8:8)
@test all(a[i] == da[i] for i in -50:50)
end
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
a81ebe9
) 100.00% compared to head (3e3e454
) 100.00%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Good catch, I forgot to have that exported. Adjusting the tests to use the new alias is probably a good idea, please add those to the PR and I'll merge.
It would be nice to export
CircularMatrix
.Ref https://github.com/Vexatos/CircularArrays.jl/pull/23