From fbb2336a5b9808646703a8045e439bd887db1e5f Mon Sep 17 00:00:00 2001 From: Dae Woo Kim Date: Wed, 29 Apr 2026 09:51:50 -0500 Subject: [PATCH] Apply runic formatting --- .github/workflows/CI.yml | 1 + Project.toml | 3 +++ src/RegisterUtilities.jl | 22 +++++++++++----------- test/runtests.jl | 22 ++++++++++++++-------- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b2a3813..6ac1e04 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,6 +14,7 @@ jobs: matrix: version: - '1.1' + - '1' os: - ubuntu-latest arch: diff --git a/Project.toml b/Project.toml index b307670..53143e8 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,9 @@ version = "0.1.0" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" RegisterCore = "67712758-55e7-5c3c-8e85-dda1d7758434" +[compat] +julia = "^1.1" + [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/RegisterUtilities.jl b/src/RegisterUtilities.jl index a392fc4..c670395 100644 --- a/src/RegisterUtilities.jl +++ b/src/RegisterUtilities.jl @@ -12,9 +12,9 @@ end Counter(sz::Tuple) = Counter(Int[sz...]) function Base.iterate(c::Counter) N = length(c.max) - (N == 0 || any(c.max.<=0)) && return nothing - state = ones(Int,N) - copy(state), state + (N == 0 || any(c.max .<= 0)) && return nothing + state = ones(Int, N) + return copy(state), state end function Base.iterate(c::Counter, state) state[1] += 1 @@ -25,7 +25,7 @@ function Base.iterate(c::Counter, state) state[i] += 1 end state[end] > c.max[end] && return nothing - copy(state), state + return copy(state), state end # Below functions are from RegisterTestUtilities @@ -37,19 +37,19 @@ export quadratic, block_center, tighten function quadratic(m, n, shift, Q) A = zeros(m, n) c = block_center(m, n) - cntr = [shift[1]+c[1], shift[2]+c[2]] + cntr = [shift[1] + c[1], shift[2] + c[2]] u = zeros(2) - for j = 1:n, i = 1:m - u[1], u[2] = i-cntr[1], j-cntr[2] - A[i,j] = dot(u,Q*u) + for j in 1:n, i in 1:m + u[1], u[2] = i - cntr[1], j - cntr[2] + A[i, j] = dot(u, Q * u) end - A + return A end quadratic(shift, Q, denom::Matrix) = MismatchArray(quadratic(size(denom)..., shift, Q), denom) function block_center(sz...) - ntuple(i->sz[i]>>1+1, length(sz)) + return ntuple(i -> sz[i] >> 1 + 1, length(sz)) end function tighten(A::AbstractArray) @@ -58,7 +58,7 @@ function tighten(A::AbstractArray) T = promote_type(T, typeof(a)) end At = similar(A, T) - copyto!(At, A) + return copyto!(At, A) end end diff --git a/test/runtests.jl b/test/runtests.jl index e577359..dc401c6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,19 +2,25 @@ using Test using RegisterUtilities @testset "Counter test" begin - for empty_gridsize in ((), (0,), (1,0), (1,-1), (1,0,1)) + for empty_gridsize in ((), (0,), (1, 0), (1, -1), (1, 0, 1)) for c in Counter(empty_gridsize) @test c == nothing end end - for (gridsize, index_vec) in (((1,),[[1]]), ((2,3),[[1,1],[2,1],[1,2],[2,2],[1,3],[2,3]]), - ((2,3,4), [[1, 1, 1],[2, 1, 1],[1, 2, 1],[2, 2, 1],[1, 3, 1],[2, 3, 1], - [1, 1, 2],[2, 1, 2],[1, 2, 2],[2, 2, 2],[1, 3, 2],[2, 3, 2], - [1, 1, 3],[2, 1, 3],[1, 2, 3],[2, 2, 3],[1, 3, 3],[2, 3, 3], - [1, 1, 4],[2, 1, 4],[1, 2, 4],[2, 2, 4],[1, 3, 4],[2, 3, 4]])) - cnt = Array{Array{Int64,1},1}() + for (gridsize, index_vec) in ( + ((1,), [[1]]), ((2, 3), [[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3]]), + ( + (2, 3, 4), [ + [1, 1, 1], [2, 1, 1], [1, 2, 1], [2, 2, 1], [1, 3, 1], [2, 3, 1], + [1, 1, 2], [2, 1, 2], [1, 2, 2], [2, 2, 2], [1, 3, 2], [2, 3, 2], + [1, 1, 3], [2, 1, 3], [1, 2, 3], [2, 2, 3], [1, 3, 3], [2, 3, 3], + [1, 1, 4], [2, 1, 4], [1, 2, 4], [2, 2, 4], [1, 3, 4], [2, 3, 4], + ], + ), + ) + cnt = Array{Array{Int64, 1}, 1}() for c in Counter(gridsize) - push!(cnt,c) + push!(cnt, c) end @test cnt == index_vec end