Skip to content

Commit

Permalink
fix bugs in all_OD_infos (oscar-system#3419)
Browse files Browse the repository at this point in the history
* fix bugs in `all_OD_infos`

* added a test
  • Loading branch information
ThomasBreuer authored Feb 26, 2024
1 parent 6ed5fc3 commit 3672388
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
60 changes: 31 additions & 29 deletions experimental/OrthogonalDiscriminants/src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,40 @@ const OD_data = JSON.parsefile(joinpath(@__DIR__, "../data/odresults.json"))

const OD_simple_names = Dict{String, String}()

@doc raw"""
OD_split_string(str::String, sep::String)
Return a vector of strings obtained by splitting `str` at characters in `sep`,
but only at those positions where the brackets `(` and `)` are balanced.
"""
function OD_split_string(str::String, sep::String)
open = 0
res = String[]
start = 0
for i in 1:length(str)
if str[i] == '('
open = open + 1
elseif str[i] == ')'
open = open - 1
elseif str[i] in sep && open == 0
push!(res, str[(start+1):(i-1)])
start = i
end
end
push!(res, str[(start+1):length(str)])

return res
end


for simpnam in OD_data["names"]
for x in OD_data[simpnam]["names"]
OD_simple_names[x] = simpnam
for p in keys(OD_data[simpnam][x])
for v in OD_data[simpnam][x][p]
v[end] = OD_split_string(v[end], ",")
end
end
end
end

Expand Down Expand Up @@ -266,32 +297,6 @@ end
__init_OD()


@doc raw"""
OD_split_string(str::String, sep::String)
Return a vector of strings obtained by splitting `str` at characters in `sep`,
but only at those positions where the brackets `(` and `)` are balanced.
"""
function OD_split_string(str::String, sep::String)
open = 0
res = String[]
start = 0
for i in 1:length(str)
if str[i] == '('
open = open + 1
elseif str[i] == ')'
open = open - 1
elseif str[i] in sep && open == 0
push!(res, str[(start+1):(i-1)])
start = i
end
end
push!(res, str[(start+1):length(str)])

return res
end


function _od_info(groupname, p, v)
return Dict{Symbol, Any}(
:groupname => groupname,
Expand Down Expand Up @@ -491,9 +496,6 @@ function all_od_infos(L...)
end
good_char || continue
for entry in D[string(char)]
if entry[end] isa String
entry[end] = OD_split_string(entry[end], ",")
end
good_dim = true
if haskey(conditions, Hecke.dim)
dim = parse(Int, filter(isdigit, entry[1]))
Expand Down
4 changes: 2 additions & 2 deletions experimental/OrthogonalDiscriminants/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function show_OD_info(tbl::Oscar.GAPGroupCharacterTable, io::IO = stdout)
if length(ppos) > 0
ppos = ppos[1]
end
if length(ppos) != 0 && !contains(ppos[end], "(indicator unknown)")
if length(ppos) != 0 && !("(indicator unknown)" in ppos[end])
# must be indicator `+`
push!(res1, _character_name(modtbls[j], k))
push!(res2, ppos[4])
Expand All @@ -364,7 +364,7 @@ function show_OD_info(tbl::Oscar.GAPGroupCharacterTable, io::IO = stdout)
# indicator `o`
push!(res1, _character_name(modtbls[j], k) *
filter(!isdigit, _character_name(modtbls[j], cc)))
push!(res2, orthogonal_discriminant_indicator0(modtbls[j][k]))
push!(res2, _orthogonal_discriminant_indicator0(modtbls[j][k]))
elseif cc == k
# indicator is *unknown*;
# note that indicator `-` (disc is "O+") cannot occur here
Expand Down
10 changes: 10 additions & 0 deletions experimental/OrthogonalDiscriminants/test/data.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
@testset "all_od_infos" begin
iob = IOBuffer()
show_OD_info("G2(3)", iob)
str1 = String(take!(iob))

all_entries = all_od_infos();
@test all_entries isa Vector

show_OD_info("G2(3)", iob)
str2 = String(take!(iob))
@test str1 == str2

@test length(all_entries) == length(all_od_infos(is_simple)) +
length(all_od_infos(! is_simple))
@test length(all_entries) == length(all_od_infos(is_sporadic_simple)) +
Expand Down

0 comments on commit 3672388

Please sign in to comment.