-
Notifications
You must be signed in to change notification settings - Fork 128
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
Improve test coverage for CartanMatrix.jl #4295
Open
felix-roehrich
wants to merge
1
commit into
oscar-system:master
Choose a base branch
from
felix-roehrich:fr/cartan-test-cov
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,27 +1,36 @@ | ||||||
@testset "LieAlgebras.CartanMatrix" begin | ||||||
@testset "cartan_matrix(fam::Symbol, rk::Int)" begin | ||||||
@testset "cartan_matrix" begin | ||||||
for i in -1:10 | ||||||
if i < 1 | ||||||
@test_throws ArgumentError cartan_matrix(:A, i) | ||||||
end | ||||||
if i < 2 | ||||||
@test_throws ArgumentError cartan_matrix(:B, i) | ||||||
end | ||||||
if i < 2 | ||||||
@test_throws ArgumentError cartan_matrix(:C, i) | ||||||
end | ||||||
if i < 4 | ||||||
@test_throws ArgumentError cartan_matrix(:D, i) | ||||||
end | ||||||
if i < 6 || i > 8 | ||||||
@test_throws ArgumentError cartan_matrix(:E, i) | ||||||
end | ||||||
if i != 4 | ||||||
@test_throws ArgumentError cartan_matrix(:F, i) | ||||||
end | ||||||
if i != 2 | ||||||
@test_throws ArgumentError cartan_matrix(:G, i) | ||||||
end | ||||||
end | ||||||
|
||||||
@test cartan_matrix(:A, 1) == matrix(ZZ, 1, 1, [2]) | ||||||
@test cartan_matrix(:A, 2) == ZZ[2 -1; -1 2] | ||||||
|
||||||
@test cartan_matrix(:B, 2) == ZZ[2 -1; -2 2] | ||||||
@test cartan_matrix(:B, 3) == ZZ[2 -1 0; -1 2 -1; 0 -2 2] | ||||||
|
||||||
@test cartan_matrix(:C, 2) == ZZ[2 -2; -1 2] | ||||||
@test cartan_matrix(:C, 3) == ZZ[2 -1 0; -1 2 -2; 0 -1 2] | ||||||
|
||||||
@test cartan_matrix(:D, 4) == ZZ[2 -1 0 0; -1 2 -1 -1; 0 -1 2 0; 0 -1 0 2] | ||||||
|
||||||
@test_throws ArgumentError root_system(:X, 1) | ||||||
@test_throws ArgumentError root_system(:A, 0) | ||||||
@test_throws ArgumentError root_system(:B, 1) | ||||||
@test_throws ArgumentError root_system(:C, 1) | ||||||
@test_throws ArgumentError root_system(:D, 2) | ||||||
@test_throws ArgumentError root_system(:E, 5) | ||||||
@test_throws ArgumentError root_system(:E, 9) | ||||||
@test_throws ArgumentError root_system(:F, 3) | ||||||
@test_throws ArgumentError root_system(:F, 5) | ||||||
@test_throws ArgumentError root_system(:G, 1) | ||||||
@test_throws ArgumentError root_system(:G, 3) | ||||||
end | ||||||
|
||||||
@testset "cartan_matrix(type::Tuple{Symbol,Int}...)" begin | ||||||
|
@@ -32,25 +41,41 @@ | |||||
@test_throws ArgumentError cartan_matrix() | ||||||
end | ||||||
|
||||||
@testset "is_cartan_matrix(mat::ZZMatrix; generalized::Bool=true)" begin | ||||||
# test finite type | ||||||
@test is_cartan_matrix(cartan_matrix(:A, 1)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:A, 1); generalized=false) == true | ||||||
|
||||||
@test is_cartan_matrix(cartan_matrix(:A, 2)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:A, 2); generalized=false) == true | ||||||
@testset "is_cartan_matrix" begin | ||||||
# test non cartan | ||||||
@test is_cartan_matrix(ZZ[2 -1; -1 1]) == false | ||||||
@testset for i in 1:3 | ||||||
is_cartan_matrix(ZZ[2 -i; 0 2]) == false | ||||||
end | ||||||
|
||||||
@test is_cartan_matrix(cartan_matrix(:B, 2)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:B, 2); generalized=false) == true | ||||||
# test finite type | ||||||
function test_is_cartan_matrix_finite_type(cm::ZZMatrix) | ||||||
rk = nrows(cm) | ||||||
for _ in 1:50 | ||||||
i, j = rand(1:rk, 2) | ||||||
if i != j | ||||||
swap_rows!(cm, i, j) | ||||||
swap_cols!(cm, i, j) | ||||||
end | ||||||
end | ||||||
|
||||||
@test is_cartan_matrix(cartan_matrix(:C, 2)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:C, 2); generalized=false) == true | ||||||
@test is_cartan_matrix(cm) == true | ||||||
@test is_cartan_matrix(cm; generalized=false) == true | ||||||
end | ||||||
|
||||||
@test is_cartan_matrix(cartan_matrix(:D, 4)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:D, 4); generalized=false) == true | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:A, 1)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:A, 3)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:B, 4)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:C, 2)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:D, 5)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:E, 6)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:E, 7)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:E, 8)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:F, 4)) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix(:G, 2)) | ||||||
|
||||||
@test is_cartan_matrix(cartan_matrix(:G, 2)) == true | ||||||
@test is_cartan_matrix(cartan_matrix(:G, 2); generalized=false) == true | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix((:A, 3), (:C, 3), (:E, 6), (:G, 2))) | ||||||
test_is_cartan_matrix_finite_type(cartan_matrix((:F, 4), (:B, 2), (:E, 7), (:G, 2))) | ||||||
|
||||||
# test affine type | ||||||
@test is_cartan_matrix(ZZ[2 -2; -2 2]) == true | ||||||
|
@@ -63,34 +88,24 @@ | |||||
@test is_cartan_matrix(ZZ[2 -1 -1; -1 2 -1; -1 -1 2]; generalized=false) == false | ||||||
end | ||||||
|
||||||
@testset "cartan_symmetrizer(gcm::ZZMatrix; check::Bool)" begin | ||||||
@testset "cartan_symmetrizer" begin | ||||||
# cartan_symmetrizer function is indirectly covered by the cartan_bilinear_form tests | ||||||
# here we simply guarantee that the choice of the symmetrizer is as expected | ||||||
|
||||||
# finite type | ||||||
@test cartan_symmetrizer(cartan_matrix(:A, 1)) == [1] | ||||||
@test cartan_symmetrizer(cartan_matrix(:A, 2)) == [1, 1] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix(:B, 2)) == [2, 1] | ||||||
@test cartan_symmetrizer(cartan_matrix(:B, 4)) == [2, 2, 2, 1] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix(:C, 2)) == [1, 2] | ||||||
@test cartan_symmetrizer(cartan_matrix(:C, 4)) == [1, 1, 1, 2] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix(:D, 4)) == [1, 1, 1, 1] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix(:E, 6)) == [1, 1, 1, 1, 1, 1] | ||||||
@test cartan_symmetrizer(cartan_matrix(:E, 7)) == [1, 1, 1, 1, 1, 1, 1] | ||||||
@test cartan_symmetrizer(cartan_matrix(:E, 8)) == [1, 1, 1, 1, 1, 1, 1, 1] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix(:F, 4)) == [2, 2, 1, 1] | ||||||
@test cartan_symmetrizer(cartan_matrix(:G, 2)) == [1, 3] | ||||||
|
||||||
@test cartan_symmetrizer(cartan_matrix((:A, 3), (:B, 3))) == [[1, 1, 1]; [2, 2, 1]] | ||||||
@test cartan_symmetrizer(cartan_matrix((:F, 4), (:D, 4))) == | ||||||
[[2, 2, 1, 1]; [1, 1, 1, 1]] | ||||||
@test cartan_symmetrizer(cartan_matrix((:C, 4), (:G, 2))) == [[1, 1, 1, 2]; [1, 3]] | ||||||
|
||||||
@test cartan_symmetrizer(ZZ[2 -2 0; -1 2 -1; 0 -1 2]) == [1, 2, 2] | ||||||
@test cartan_symmetrizer(ZZ[2 0 -1 0; 0 2 0 -2; -2 0 2 0; 0 -1 0 2]) == [2, 1, 1, 2] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are still indirectly tested via the bilinear form test below, right? |
||||||
|
||||||
# affine type | ||||||
@test cartan_symmetrizer(ZZ[2 -2; -2 2]) == [1, 1] # A1~1 | ||||||
@test cartan_symmetrizer(ZZ[2 -2 0; -1 2 -1; 0 -2 2]) == [1, 2, 1] # D3~2 | ||||||
|
@@ -100,20 +115,37 @@ | |||||
@test cartan_symmetrizer(ZZ[2 -2; -3 2]) == [3, 2] | ||||||
end | ||||||
|
||||||
@testset "cartan_bilinear_form(gcm::ZZMatrix; check::Bool)" begin | ||||||
# finite type | ||||||
@test cartan_bilinear_form(cartan_matrix(:A, 2)) == ZZ[2 -1; -1 2] | ||||||
@test cartan_bilinear_form(cartan_matrix(:B, 4)) == | ||||||
ZZ[4 -2 0 0; -2 4 -2 0; 0 -2 4 -2; 0 0 -2 2] | ||||||
@test cartan_bilinear_form(cartan_matrix(:C, 4)) == | ||||||
ZZ[2 -1 0 0; -1 2 -1 0; 0 -1 2 -2; 0 0 -2 4] | ||||||
@test cartan_bilinear_form(cartan_matrix(:F, 4)) == | ||||||
ZZ[4 -2 0 0; -2 4 -2 0; 0 -2 2 -1; 0 0 -1 2] | ||||||
@test cartan_bilinear_form(cartan_matrix(:G, 2)) == ZZ[2 -3; -3 6] | ||||||
|
||||||
@test cartan_bilinear_form(cartan_matrix((:B, 2), (:A, 1))) == ZZ[4 -2 0; -2 2 0; 0 0 2] | ||||||
@test cartan_bilinear_form(ZZ[2 0 -1 0; 0 2 0 -2; -2 0 2 0; 0 -1 0 2]) == | ||||||
ZZ[4 0 -2 0; 0 2 0 -2; -2 0 2 0; 0 -2 0 4] | ||||||
@testset "cartan_bilinear_form" begin | ||||||
function test_cartan_bilinear_form(cm::ZZMatrix) | ||||||
rk = nrows(cm) | ||||||
for _ in 1:50 | ||||||
i, j = rand(1:rk, 2) | ||||||
if i != j | ||||||
swap_rows!(cm, i, j) | ||||||
swap_cols!(cm, i, j) | ||||||
end | ||||||
end | ||||||
|
||||||
bil = cartan_bilinear_form(cm) | ||||||
@test is_symmetric(bil) == true | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
@test all(cm[i, j] == div(2 * bil[i, j], bil[i, i]) for i in 1:rk, j in 1:rk) | ||||||
end | ||||||
|
||||||
# irreducible matrices | ||||||
test_cartan_bilinear_form(cartan_matrix(:A, 1)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:A, 3)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:B, 4)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:C, 2)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:D, 5)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:E, 6)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:E, 7)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:E, 8)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:F, 4)) | ||||||
test_cartan_bilinear_form(cartan_matrix(:G, 2)) | ||||||
|
||||||
# reducible matrices | ||||||
test_cartan_bilinear_form(cartan_matrix((:A, 3), (:C, 3), (:E, 6), (:G, 2))) | ||||||
test_cartan_bilinear_form(cartan_matrix((:F, 4), (:B, 2), (:E, 7), (:G, 2))) | ||||||
|
||||||
# affine type | ||||||
@test cartan_bilinear_form(ZZ[2 -2; -2 2]) == ZZ[2 -2; -2 2] | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you transform this block of tests into tests for
is_cartan_type
and then test the cartan matrix constructor via?