Ask Your Question
0

How to connect Magma_free, SAGE and GAP (problem concerning a MAGMA string not readable by GAP)?

asked 2019-02-01 17:23:52 +0200

Bern gravatar image

updated 2019-08-29 18:39:01 +0200

FrédéricC gravatar image

Hi,

I'd like to ask the following:

I'd like to use SAGE in order to compute something with the free magma online calculator and then convert it into a GAP object. Unfortunately, there occurs an error, and I don't know, how to fix this. Any help is very much appreciated.

I followed the example on page 91 of http://www.math.rwth-aachen.de/~Thoma...

Here is what I did:

sage: gap.LoadPackage('"ctbllib"');
sage: ct=magma_free("G:=Alt(5);ct:=CharacterTable(G);ct;")
sage: tmpdir = gap.DirectoryTemporary()
sage: file=gap.Filename(tmpdir, '"magmatable"')
sage: gap.FileString(file,ct)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-fd546564c72c> in <module>()
----> 1 gap.FileString(file,ct)

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, *args, **kwds)
    627 
    628     def __call__(self, *args, **kwds):
--> 629         return self._parent.function_call(self._name, list(args), kwds)
    630 
    631     def _instancedoc_(self):

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in function_call(self, function, args, kwds)
    921 
    922         """
--> 923         args, kwds = self._convert_args_kwds(args, kwds)
    924         self._check_valid_function_name(function)
    925 

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _convert_args_kwds(self, args, kwds)
    530         for i, arg in enumerate(args):
    531             if not isinstance(arg, InterfaceElement) or arg.parent() is not self:
--> 532                 args[i] = self(arg)
    533         for key, value in iteritems(kwds):
    534             if not isinstance(value, InterfaceElement) or value.parent() is not self:

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
    278 
    279         if isinstance(x, string_types):
--> 280             return cls(self, x, name=name)
    281         try:
    282             return self._coerce_from_special_method(x)

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
   1443             except (RuntimeError, ValueError) as x:
   1444                 self._session_number = -1
-> 1445                 raise_(TypeError, TypeError(*x.args), sys.exc_info()[2])
   1446             except BaseException:
   1447                 self._session_number = -1

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc in __init__(self, parent, value, is_name, name)
   1438         else:
   1439             try:
-> 1440                 self._name = parent._create(value, name=name)
   1441             # Convert ValueError and RuntimeError to TypeError for
   1442             # coercion to work properly.

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in _create(self, value, name)
    474     def _create(self, value, name=None):
    475         name = self._next_var_name() if name is None else name
--> 476         self.set(name, value)
    477         return name
    478 

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in set(self, var, value)
   1387         """
   1388         cmd = ('%s:=%s;;' % (var, value)).replace('\n','')
-> 1389         self._eval_line(cmd, allow_use_file=True)
   1390 
   1391     def get(self, var, use_file=False):

/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/gap.pyc in _eval_line(self, line, allow_use_file,         
wait_for_prompt, restart_if_needed)
    787                     return ''
    788             else:
--> 789                 raise RuntimeError(message)
    790 
    791         except KeyboardInterrupt:

TypeError: Gap terminated unexpectedly while reading in a large line:
Gap produced error output
Syntax error: ; expected in /home/boehmler/.sage/temp/mahlzahn/8255/interface/\
tmp8325 line 1
\$sage2:=Character Table of Group G-------------------------------------------\
----------Class |   1  2  3    4    5Size  |   1 15 20   12   12Order |   1  2\
  3    5    5---------------------------p  =  2   1  1  3    5    4p  =  3   1\
  2  1    5    4p  =  5   1  2  3    1    1---------------------------X.1   + \
  1  1  1    1    1X.2   +   3 -1  0   Z1 Z1#2X.3   +   3 -1  0 Z1#2   Z1X.4  \
 +   4  0  1   -1   -1X.5   +   5  1 -1    0    0Explanation of Character Valu\
e Symbols--------------------------------------# denotes algebraic conjugation\
, that is,#k indicates replacing the root of unity w by w^kZ1     = (Cyclotomi\
cField(5: Sparse := true)) ! [ RationalField() | 0, 0, -1, -1 ];;
                       ^

   executing Read("/home/boehmler/.sage/temp/mahlzahn/8255/interface/tmp8325");
sage:
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-02-01 19:03:39 +0200

nbruin gravatar image

Note that

sage: gap("19+5")
24

so feeding a string to the gap interface tries to interpret it as input. With gap.FileString, this will probably happen with the string you want to write to a file as well. In any case, writing this long string in python to a file by transferring it to a gap process is rather inefficient anyway. It's much better to write the string into a file straight from python and then read that file into GAP using the gap routine you would like to use.

edit flag offensive delete link more

Comments

Thank you very much for your answer! :-)

To whom it may concern: In the meantime I got to know that the following is also a possible solution (exemplarily done for G=$S_4$):

gap.LoadPackage('"ctbllib"')

ct=magma_free("G:=Sym(4);ct:=CharacterTable(G);ct;")

myfile=file("tbl_MAGMA.txt", 'w')

print >> myfile, ct

print >> myfile.close()

tbl=gap.GAPTableOfMagmaFile('"tbl_MAGMA.txt"', '"MAGMA_TBL"')

gap.Display(tbl)

G=gap.SymmetricGroup(4)

gap.ConnectGroupAndCharacterTable(G,tbl)

Bern gravatar imageBern ( 2019-11-08 19:01:16 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-01 17:23:52 +0200

Seen: 398 times

Last updated: Feb 01 '19