1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-26 02:20:30 +01:00

Merge pull request #8 from kalmarek/enh/github_actions

add github workflow runtests
This commit is contained in:
kalmarek 2020-04-20 01:02:47 +02:00 committed by GitHub
commit 38f121d8ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 6 deletions

42
.github/workflows/runtests.yml vendored Normal file
View File

@ -0,0 +1,42 @@
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
- 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 }}

View File

@ -7,7 +7,7 @@ import AbstractAlgebra: order, gens, matrix_repr
import Base: length, ==, hash, show, convert, eltype, iterate import Base: length, ==, hash, show, convert, eltype, iterate
import Base: inv, reduce, *, ^, power_by_squaring import Base: inv, reduce, *, ^, power_by_squaring
import Base: findfirst, findnext, replace import Base: findfirst, findnext, findlast, findprev, replace
import Base: deepcopy_internal import Base: deepcopy_internal
using LinearAlgebra using LinearAlgebra

View File

@ -36,6 +36,8 @@ Base.@propagate_inbounds function Base.getindex(w::GWord, i::Integer)
return first(syllables(w)[idx]) return first(syllables(w)[idx])
end end
Base.@propagate_inbounds Base.getindex(w::GWord, itr) = [w[i] for i in itr]
# no setindex! for syllable based words # no setindex! for syllable based words
Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s) Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s)

View File

@ -36,12 +36,14 @@ end
@test isa(Vector{FreeGroupElem}([s,t]), Vector{FreeGroupElem}) @test isa(Vector{FreeGroupElem}([s,t]), Vector{FreeGroupElem})
@test length(FreeGroupElem(s)) == 1 @test length(FreeGroupElem(s)) == 1
@test length(FreeGroupElem(t)) == 2 @test length(FreeGroupElem(t)) == 2
@test Groups.FreeSymbol(:s, 1) != Groups.FreeSymbol(:s, 2)
@test Groups.FreeSymbol(:s, 1) != Groups.FreeSymbol(:t, 1)
end end
@testset "FreeGroup" begin @testset "FreeGroup" begin
@test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group) @test isa(FreeGroup(["s", "t"]), AbstractAlgebra.Group)
G = FreeGroup(["s", "t"]) G = FreeGroup(["s", "t"])
s, t = gens(G)
@testset "elements constructors" begin @testset "elements constructors" begin
@test isa(one(G), FreeGroupElem) @test isa(one(G), FreeGroupElem)
@ -49,9 +51,23 @@ end
@test length(G.gens) == 2 @test length(G.gens) == 2
@test eltype(gens(G)) == FreeGroupElem @test eltype(gens(G)) == FreeGroupElem
@test length(gens(G)) == 2 @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]
@test Groups.GroupWord([tt, inv(tt)]) isa FreeGroupElem
end
@testset "internal arithmetic" begin @testset "internal arithmetic" begin
@ -98,7 +114,7 @@ end
@test o*p == one(parent(o*p)) @test o*p == one(parent(o*p))
w = FreeGroupElem([o.symbols..., p.symbols...]) w = FreeGroupElem([o.symbols..., p.symbols...])
w.parent = G w.parent = G
@test Groups.reduce!(w).symbols ==Vector{Groups.FreeSymbol}([]) @test Groups.syllables(Groups.reduce(w)) == Vector{Groups.FreeSymbol}([])
end end
@testset "Group operations" begin @testset "Group operations" begin
@ -130,6 +146,12 @@ end
@test findnext(s^-1*t^-1, c*s^-1,3) == 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 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 w = s*t*s^-1
subst = Dict{FreeGroupElem, FreeGroupElem}(w => s^1, s*t^-1 => t^4) subst = Dict{FreeGroupElem, FreeGroupElem}(w => s^1, s*t^-1 => t^4)
@test Groups.replace(c, s*t=>one(G)) == s^-1*t^-1 @test Groups.replace(c, s*t=>one(G)) == s^-1*t^-1