# If statement to avoid running GAP structure_description

I am using the operation structure_description to see if a finitely presented group can be recognized and labeled by Sage. Sometimes, this works fine, for example:

G1=H1/[H1(Rel[i]) for i in range(g+g*len(Y)+len(GG))];G1
Finitely presented group < x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17 | x4*x0^-1*x3, x2*x1*x0, x5^-1*x2^-1*x4^-1, x5*x3^-1*x1^-1, x10*x12^-1*x15, x8*x7*x12, x11^-1*x8^-1*x10^-1, x11*x15^-1*x7^-1, x16*x6^-1*x9, x14*x13*x6, x17^-1*x14^-1*x16^-1, x17*x9^-1*x13^-1, 1, x0, x0^2, x0, x6*x12, x1, x7*x13, x2, x8, x14, x3, x9*x15, x4, x10, x16, x5, x11, x17 >
G1.structure_description()
'C0'


However, in other cases it fails, for example:

G1=H1/[H1(Rel[i]) for i in range(g+g*len(Y)+len(GG))];G1
Finitely presented group < x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17 | x4*x6^-1*x9, x2*x1*x12, x17^-1*x8^-1*x4^-1, x5*x15^-1*x1^-1, x10*x12^-1*x15, x8*x13*x6, x5^-1*x2^-1*x10^-1, x11*x3^-1*x7^-1, x16*x0^-1*x3, x14*x7*x0, x11^-1*x14^-1*x16^-1, x17*x9^-1*x13^-1, 1, x0, x0*x12, x0*x12, x6, x1*x13*x7, x2, x8*x14, x3*x15*x9, x4*x10, x16, x5*x11*x17 >
G1.structure_description()
GAPError: Error, no method found! Error, no 4th choice method found for StructureDescription' on 1 arguments


So the fact that this happens is very understandable - I understand it as being somehow related to the word problem. But I am running this script for many finite groups, and if this information is available, I want Sage to find it and print it - otherwise skip it. Right now, every time the script hits a case, it just fails and exits.

Is there some kind of if ...structure_description=TRUE I could wrap this line in, so that it only executes if it's going to actually work?

edit retag close merge delete

Sort by » oldest newest most voted

Using

try:
code
except GAPError:
pass
`
more

Ohhh python magic :-) Yes, this worked - I just had to use ValueError instead of GAPError: https://doc.sagemath.org/html/en/refe...

( 2022-06-14 16:02:06 +0200 )edit

Please start posting anonymously - your entry will be published after you log in or create a new account.

## Stats

Asked: 2022-06-13 16:26:01 +0200

Seen: 29 times

Last updated: Jun 13