-
Notifications
You must be signed in to change notification settings - Fork 12
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
export CircularMatrix #25
export CircularMatrix #25
Conversation
Should I update 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 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #25 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 48 50 +2
=========================================
+ Hits 48 50 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Good catch, I forgot to have that exported. |
It would be nice to export
CircularMatrix
.Ref #23