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

export CircularMatrix #25

Merged
merged 3 commits into from
Jan 19, 2024
Merged

Conversation

terasakisatoshi
Copy link
Contributor

It would be nice to export CircularMatrix.

Ref #23

@terasakisatoshi
Copy link
Contributor Author

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

Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a81ebe9) 100.00% compared to head (3e3e454) 100.00%.

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vexatos
Copy link
Owner

Vexatos commented Jan 15, 2024

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.

@Vexatos Vexatos merged commit ec93323 into Vexatos:master Jan 19, 2024
11 checks passed
@terasakisatoshi terasakisatoshi deleted the export-CircularMatrix branch January 19, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants