From d94be2df4b7fa063e0b2db539a095d8aa904c4c1 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Apr 2020 00:04:09 +0200 Subject: [PATCH 1/4] add github workflow runtests --- .github/workflows/runtests.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/runtests.yml diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml new file mode 100644 index 0000000..f653733 --- /dev/null +++ b/.github/workflows/runtests.yml @@ -0,0 +1,34 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - '1.3' + - '1.4' + - 'nightly' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + fail-fast: false + + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest From ea7813b5dca07d972aa91b1264a1a38d74f17463 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Apr 2020 00:19:39 +0200 Subject: [PATCH 2/4] add codecov --- .github/workflows/runtests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index f653733..3c62d95 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -32,3 +32,11 @@ jobs: arch: ${{ matrix.arch }} - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: ./lcov.info + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} From dfce36c09973addebe793182ee0647a38c7d4fe9 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Apr 2020 00:36:35 +0200 Subject: [PATCH 3/4] add tests for iteration for GWords --- src/words.jl | 2 ++ test/FreeGroup-tests.jl | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/words.jl b/src/words.jl index 9ef7383..1a1c76e 100644 --- a/src/words.jl +++ b/src/words.jl @@ -36,6 +36,8 @@ Base.@propagate_inbounds function Base.getindex(w::GWord, i::Integer) return first(syllables(w)[idx]) end +Base.@propagate_inbounds Base.getindex(w::GWord, itr) = [w[i] for i in itr] + # no setindex! for syllable based words Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s) diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index da39e75..09924df 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -42,6 +42,7 @@ end @testset "FreeGroup" begin @test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group) G = FreeGroup(["s", "t"]) + s, t = gens(G) @testset "elements constructors" begin @test isa(one(G), FreeGroupElem) @@ -49,9 +50,21 @@ end @test length(G.gens) == 2 @test eltype(gens(G)) == FreeGroupElem @test length(gens(G)) == 2 - end - s, t = gens(G) + @test collect(s*t) == Groups.syllables(s*t) + tt, ss = Groups.FreeSymbol(:t), Groups.FreeSymbol(:s) + @test collect(t^2) == [tt, tt] + ttinv = Groups.FreeSymbol(:t, -1) + w = t^-2*s^3*t^2 + @test collect(w) == [inv(tt), inv(tt), ss, ss, ss, tt, tt] + @test w[1] == inv(tt) + @test w[2] == inv(tt) + @test w[3] == ss + @test w[3:5] == [ss, ss, ss] + @test w[end] == tt + + @test collect(ttinv) == [ttinv] + end @testset "internal arithmetic" begin From 7517a8feb967a52f781c93a26996a536d0ca74e4 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Mon, 20 Apr 2020 00:52:06 +0200 Subject: [PATCH 4/4] tests and imports for findlast, findprev --- src/Groups.jl | 2 +- test/FreeGroup-tests.jl | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Groups.jl b/src/Groups.jl index 9dc67cb..4312ac2 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -7,7 +7,7 @@ import AbstractAlgebra: order, gens, matrix_repr import Base: length, ==, hash, show, convert, eltype, iterate import Base: inv, reduce, *, ^, power_by_squaring -import Base: findfirst, findnext, replace +import Base: findfirst, findnext, findlast, findprev, replace import Base: deepcopy_internal using LinearAlgebra diff --git a/test/FreeGroup-tests.jl b/test/FreeGroup-tests.jl index 09924df..7a4e720 100644 --- a/test/FreeGroup-tests.jl +++ b/test/FreeGroup-tests.jl @@ -36,7 +36,8 @@ end @test isa(Vector{FreeGroupElem}([s,t]), Vector{FreeGroupElem}) @test length(FreeGroupElem(s)) == 1 @test length(FreeGroupElem(t)) == 2 - + @test Groups.FreeSymbol(:s, 1) != Groups.FreeSymbol(:s, 2) + @test Groups.FreeSymbol(:s, 1) != Groups.FreeSymbol(:t, 1) end @testset "FreeGroup" begin @@ -64,6 +65,8 @@ end @test w[end] == tt @test collect(ttinv) == [ttinv] + + @test Groups.GroupWord([tt, inv(tt)]) isa FreeGroupElem end @testset "internal arithmetic" begin @@ -96,7 +99,7 @@ end @test o*p == one(parent(o*p)) w = FreeGroupElem([o.symbols..., p.symbols...]) w.parent = G - @test Groups.reduce!(w).symbols ==Vector{Groups.FreeSymbol}([]) + @test Groups.syllables(Groups.reduce(w)) == Vector{Groups.FreeSymbol}([]) end @testset "Group operations" begin @@ -126,8 +129,14 @@ end c = s*t*s^-1*t^-1 @test findfirst(s^-1*t^-1, c) == 3 @test findnext(s^-1*t^-1, c*s^-1,3) == 3 - @test findnext(s^-1*t^-1, c*s^-1*t^-1,4) == 5 + @test findnext(s^-1*t^-1, c*s^-1*t^-1, 4) == 5 @test findfirst(c, c*t) === nothing + + @test findlast(s^-1*t^-1, c) == 3 + @test findprev(s, s*t*s*t, 4) == 3 + @test findprev(s*t, s*t*s*t, 2) == 1 + @test findlast(t^2*s, c) === nothing + w = s*t*s^-1 subst = Dict{FreeGroupElem, FreeGroupElem}(w => s^1, s*t^-1 => t^4) @test Groups.replace(c, s*t=>one(G)) == s^-1*t^-1