Gap Undeposited Implementations

6 views
Skip to first unread message

Adam Sorkin

unread,
Nov 4, 2009, 10:27:40 PM11/4/09
to sage-support
I am trying to load a Gap package for braid orbit computations. I
would like to run everything through Sage if possible. This is an
undeposited Implementation, so running "sage -i gap_packages-4.4.10_4
" doesn't retrieve this package. I'm running this on OSX, 10.5, and
have gap_version() = 4.4.10. I've downloaded and unzipped the package.
I've tried the instructions:


in sage, in gap_console()
Read("assemble.g");


and get the message

"Error, file must exist and be readable called from <function>
( <arguments> ) called from read-eval-loop
Entering break read-eval-print loop ..."

Any suggestions?

Adam

Robert Bradshaw

unread,
Nov 4, 2009, 10:37:20 PM11/4/09
to sage-s...@googlegroups.com

I'm no expert, but for installation you could try

sage -gap [[[whatever it takes to install packages normally]]]

- Robert

Adam Sorkin

unread,
Nov 4, 2009, 11:03:53 PM11/4/09
to sage-support
Well, I'm not sure how to normally install it. The directions are on
the author's site (http://www.math.wayne.edu/~kaym/research/), and say
to download a folder, then

"The files appear in a subdirectory called "braid". Open a GAP window
and type
Read("assemble.g"). This reads all the program files."

I've downloaded the folder, and that's where I've been stuck.

Adam

On Nov 4, 7:37 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Robert Bradshaw

unread,
Nov 4, 2009, 11:09:20 PM11/4/09
to sage-s...@googlegroups.com
On Nov 4, 2009, at 8:03 PM, Adam Sorkin wrote:

> Well, I'm not sure how to normally install it. The directions are on
> the author's site (http://www.math.wayne.edu/~kaym/research/), and say
> to download a folder, then
>
> "The files appear in a subdirectory called "braid". Open a GAP window
> and type
> Read("assemble.g"). This reads all the program files."
>
> I've downloaded the folder, and that's where I've been stuck.

Are you using Sage via the notebook, or the command line? If from the
command line, cd into the directory you downloaded, and then run sage
there.

sage: gap('Read("assemble.g")')

I would imagine that would do the trick. If from the notebook, you
might have to

sage: os.chdir("/path/to/files")
sage: gap('Read("assemble.g")')

- Robert

Adam Sorkin

unread,
Nov 4, 2009, 11:28:13 PM11/4/09
to sage-support
Thank you for the help. I needed to go to the proper directory. I was
able to get it to run in the gap command prompt using
Read("assemble.g");

But, when I tried to run it in Sage with

gap('Read("assemble.g")')

I received a Type Error, with output

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in __call__(self, x, name)
1022
1023 if isinstance(x, basestring):
-> 1024 return cls(self, x, name=name)
1025 try:
1026 return self._coerce_from_special_method(x)

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in __init__(self, parent, value, is_name, name)
1426 except (TypeError, KeyboardInterrupt,
RuntimeError, ValueError), x:
1427 self._session_number = -1
-> 1428 raise TypeError, x
1429 self._session_number = parent._session_number
1430

TypeError: Gap produced error output
Function call: <func> must return a value

executing $sage2:=Read("assemble.g");;


But I can run it in the gap console inside of Sage, and that works for
now. Thanks again!

Adam

On Nov 4, 8:09 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

David Joyner

unread,
Nov 5, 2009, 12:13:08 AM11/5/09
to sage-s...@googlegroups.com
On Wed, Nov 4, 2009 at 10:27 PM, Adam Sorkin <azso...@hotmail.com> wrote:
>
> I am trying to load a Gap package for braid orbit computations. I
> would like to run everything through Sage if possible. This is an
> undeposited Implementation,  so running "sage -i gap_packages-4.4.10_4
> " doesn't retrieve this package. I'm running this on OSX, 10.5, and
> have gap_version() = 4.4.10. I've downloaded and unzipped the package.


I created (with Kay Maagard's permission) a GAP package from those
braid files. You'll find it at http://www.gap-system.org/Packages/undep.html
Unpack the tarball into sage*/local/lib/gap*/pkg and then start GAP
from within Sage (using sage -gap, for example, or gap_console())
and then type LoadPackage("braid");


I dont know of anyone else but me that has trying this out, so please
let me know if it fails.

William Stein

unread,
Nov 5, 2009, 12:28:44 AM11/5/09
to sage-s...@googlegroups.com

Instead, just do

sage: gap.eval('Read("assemble.g")')

William

Adam Sorkin

unread,
Nov 5, 2009, 1:10:38 AM11/5/09
to sage-support
I haven't been able to get it to work that way. I did already have a
file 'braid' in pkg, but it doesn't have all the files the one I
downloaded did.
After unpacking the tarball as you said, I ran gap_console(), and then

GAP4, Version: 4.4.10 of 02-Oct-2007, i686-apple-darwin9.7.0-gcc
gap> LoadPackage("braid");
true
gap> g:=SymmetricGroup(3);;
gap> t:=[(1,2)];;
gap> Braid(g,t);
Variable: 'Braid' must have a value


which was the same thing I'd get in the beginning, when Braid wasn't
recognized as a program.



On Nov 4, 9:13 pm, David Joyner <wdjoy...@gmail.com> wrote:
> On Wed, Nov 4, 2009 at 10:27 PM, Adam Sorkin <azsor...@hotmail.com> wrote:
>
> > I am trying to load a Gap package for braid orbit computations. I
> > would like to run everything through Sage if possible. This is an
> > undeposited Implementation,  so running "sage -i gap_packages-4.4.10_4
> > " doesn't retrieve this package. I'm running this on OSX, 10.5, and
> > have gap_version() = 4.4.10. I've downloaded and unzipped the package.
>
> I created (with Kay Maagard's permission) a GAP package from those
> braid files. You'll find it athttp://www.gap-system.org/Packages/undep.html

David Joyner

unread,
Nov 5, 2009, 1:27:42 AM11/5/09
to sage-s...@googlegroups.com
On Thu, Nov 5, 2009 at 1:10 AM, Adam Sorkin <azso...@hotmail.com> wrote:
>
> I haven't been able to get it to work that way. I did already have a
> file 'braid' in pkg, but it doesn't have all the files the one I
> downloaded did.


I just noticed that the link on the GAP website I gave you for the
braid tarball
is bad. I'll fix it soon. Here is the correct one:
http://www.usna.edu/Users/math/wdj/gap/braid.tar.gz


> After unpacking the tarball as you said, I ran gap_console(), and then
>
> GAP4, Version: 4.4.10 of 02-Oct-2007, i686-apple-darwin9.7.0-gcc
> gap> LoadPackage("braid");
> true
> gap> g:=SymmetricGroup(3);;
> gap> t:=[(1,2)];;
> gap> Braid(g,t);
> Variable: 'Braid' must have a value
>
>
> which was the same thing I'd get in the beginning, when Braid wasn't
> recognized as a program.


I however, get a different error:

jeeves:sage-4.2 wdj$ ./sage
----------------------------------------------------------------------
| Sage Version 4.2, Release Date: 2009-10-24 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: gap_console()
GAP4, Version: 4.4.10 of 02-Oct-2007, i686-apple-darwin10.0.0-gcc
gap> LoadPackage("braid");
Variable: 'MinimumWeight' is read only
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' after making it writable to continue

Unfortunately, I have no idea what this means. Maybe the GAP
package loading mechanism has changed in some way I don't know about.
I'll keep testing.

In any case, the general idea is that you *should* be able to simply drop
any GAP package into sage*/local/lib/gap*/pkg and then start GAP
from within Sage and then type LoadPackage.

Sorry for the hassle with this.

Simon King

unread,
Nov 5, 2009, 4:02:02 AM11/5/09
to sage-support
Hi!

On Nov 5, 5:13 am, David Joyner <wdjoy...@gmail.com> wrote:
[...]
> Unpack the tarball into sage*/local/lib/gap*/pkg and then start GAP
> from within Sage (using sage -gap, for example, or gap_console())
> and then type LoadPackage("braid");

Sorry that I did not read the whole thread; perhaps the following was
already mentioned?

Some GAP packages, comprising more than just GAP code, require some "./
configure" and "make" business after unpacking the tar-ball in
SAGE_ROOT/local/lib/gap*/pkg. This should probably be done in a sage-
shell, hence, running "sage -sh"

In some cases it is needed to start sage and do
sage: gap_reset_workspace()
before being able to use a freshly installed GAP package.

Cheers,
Simon

Adam Sorkin

unread,
Nov 5, 2009, 1:11:47 PM11/5/09
to sage-support
Moving to a directly having the braid files, I get

sage: gap.eval('Read("assemble.g")')
' '

but when I try to run Braid, I get the error

sage: Braid(g,t)
---------------------------------------------------------------------------
NameError Traceback (most recent call
last)

/Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()

NameError: name 'Braid' is not defined



On Nov 4, 9:28 pm, William Stein <wst...@gmail.com> wrote:

William Stein

unread,
Nov 5, 2009, 1:59:38 PM11/5/09
to sage-s...@googlegroups.com
On Thu, Nov 5, 2009 at 10:11 AM, Adam Sorkin <azso...@hotmail.com> wrote:
>
> Moving to a directly having the braid files, I get
>
> sage: gap.eval('Read("assemble.g")')
> ' '
>
> but when I try to run Braid, I get the error
>
> sage: Braid(g,t)
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call
> last)
>
> /Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()
>
> NameError: name 'Braid' is not defined

Try

sage: gap.eval("Braid(g,t)")

David Joyner

unread,
Nov 5, 2009, 4:26:26 PM11/5/09
to sage-s...@googlegroups.com
Okay. Here is what will work.

The package loading mechanism has changed so my quick hack
to create a package from Maagard et al's files will not work
now. I'll try to fix it eventually when I have time...

1. Download and extract Maagard's tarball anywhere, say to
/Users/me/gapfiles/braid
(so /Users/me/gapfiles/braid/assemble.g is a file on your machine).
2. Edit all lines in assemble of the form
Read("blahblah");
to say
Read("/Users/me/gapfiles/braid/blahblah");
3. Start GAP in sage by sage -gap. The following should work:


gap> Read("/Users/wdj/computer_algebra/gapfiles/braid_dir2/assemble.g");
gap> g:=SymmetricGroup(3);;
gap> t:=[(1,2), (1,2)];;
gap> Braid(g,t);
Thu Nov 5 16:16:38 EST 2009



Collecting 20 random tuples... done
Cleaning done; 20 random tuples remaining


Orbit 1:
Length=1
Generated subgroup size=2
Centralizer size=2
Remaining portion of structure constant=0
Cleaning current orbit... done; 0 random tuples remaining

Thu Nov 5 16:16:38 EST 2009
Summary: orbits of generating tuples



Note/Question: gap_console() does not work, *I think* because
it does not start GAP using the -A flag. Does this make sense to
anyone? Is there a way to add an option to gap_console so that
GAP can be started in Sage using any of the available GAP flags?

Adam Sorkin

unread,
Nov 6, 2009, 2:07:43 PM11/6/09
to sage-support
I can run Braid in gap_console() inside of Sage. Trying to run it in
Sage proper gives gives the following run-time error:

sage: gap.eval('Read("assemble.g")')
''
sage: g=SymmetricGroup(3)
sage: t=[(2,1),(2,1),(2,1),(2,1)]
sage: gap.eval("Braid(g,t)")
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call
last)

/Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
gap.pyc in eval(self, x, newlines, strip, **kwds)
478 input_line += ';'
479
--> 480 result = Expect.eval(self, input_line, **kwds)
481
482 if not newlines:

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in eval(self, code, strip, synchronize, locals, **kwds)
973 try:
974 with gc_disabled():
--> 975 return '\n'.join([self._eval_line(L, **kwds)
for L in code.split('\n') if L != ''])
976 except KeyboardInterrupt:
977 # DO NOT CATCH KeyboardInterrupt, as it is being
caught

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
gap.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt)
720 return ''
721 else:
--> 722 raise RuntimeError, message
723
724 except KeyboardInterrupt:

RuntimeError: Gap produced error output
Variable: 'g' must have a value


executing Braid(g,t);
sage:

Notice I'm running Sage in a directory on my desktop containing the
Braid files.

Adam


On Nov 5, 10:59 am, William Stein <wst...@gmail.com> wrote:

Robert Bradshaw

unread,
Nov 6, 2009, 2:21:36 PM11/6/09
to sage-s...@googlegroups.com
On Nov 6, 2009, at 11:07 AM, Adam Sorkin wrote:

> I can run Braid in gap_console() inside of Sage. Trying to run it in
> Sage proper gives gives the following run-time error:
>
> sage: gap.eval('Read("assemble.g")')
> ''
> sage: g=SymmetricGroup(3)
> sage: t=[(2,1),(2,1),(2,1),(2,1)]
> sage: gap.eval("Braid(g,t)")

Gap and Sage each have their own environments. The Braid package lives
entirely inside Gap, and can't be directly called with things in the
Sage environment, Sage can just ask Gap to do things in the Gap
environment. What you can do is

sage: g=SymmetricGroup(3)
sage: t=[(2,1),(2,1),(2,1),(2,1)]

sage: gap.eval("Braid(%s,%s)" % gap(g), gap(t))

Even easier, you can do

sage: gap.Braid(g, t)

which will create copies of g and t in the gap environment, call gap's
Braid() on them, then return the result.

- Robert

David Joyner

unread,
Nov 7, 2009, 9:32:21 AM11/7/09
to sage-s...@googlegroups.com
I posted a new version of the braid package at
http://www.opensourcemath.org/braid/
If you extract it in sage*/local/lib/gap*/pkg and then start GAP
by sage -gap, then it loads using
gap> LoadPackage("braid");


On Wed, Nov 4, 2009 at 10:27 PM, Adam Sorkin <azso...@hotmail.com> wrote:
>

Adam Sorkin

unread,
Nov 9, 2009, 11:58:56 AM11/9/09
to sage-support
I'd like to do it this way, running everything through sage, but it
doesn't work. Here is what I'm getting:

sage: g = SymmetricGroup(3)
sage: t = [(2,1),(2,1)]
sage: gap.Braid(g,t)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call
last)

/Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in __call__(self, *args, **kwds)
1356
1357 def __call__(self, *args, **kwds):
-> 1358 return self._parent.function_call(self._name, list
(args), kwds)
1359
1360 def _sage_doc_(self):

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
gap.pyc in function_call(self, function, args, kwds)
883 self.eval('$__SAGE_LAST__ := %s;;'%marker)
884 res = self.eval("%s(%s)"%(function, ",".join([s.name()
for s in args]+
--> 885 ['%s=%s'%
(key,value.name()) for key, value in kwds.items()])))
886
887 if gap.eval('last') != marker:

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
gap.pyc in eval(self, x, newlines, strip, **kwds)
478 input_line += ';'
479
--> 480 result = Expect.eval(self, input_line, **kwds)
481
482 if not newlines:

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
expect.pyc in eval(self, code, strip, synchronize, locals, **kwds)
973 try:
974 with gc_disabled():
--> 975 return '\n'.join([self._eval_line(L, **kwds)
for L in code.split('\n') if L != ''])
976 except KeyboardInterrupt:
977 # DO NOT CATCH KeyboardInterrupt, as it is being
caught

/Applications/sage/local/lib/python2.5/site-packages/sage/interfaces/
gap.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt)
720 return ''
721 else:
--> 722 raise RuntimeError, message
723
724 except KeyboardInterrupt:

RuntimeError: Gap produced error output
Error, no 1st choice method found for `IsConjugate' on 3 arguments

executing Braid($sage9,$sage16);



I get a different error using
gap.eval("Braid(%s,%s)" % gap(g), gap(t))

Specifically,

sage: gap.eval("Braid(%s,%s)" % gap(g), gap(t) )
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)

/Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()

TypeError: not enough arguments for format string


Perhaps this one is easier to fix.

Adam


On Nov 6, 11:21 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> On Nov 6, 2009, at 11:07 AM, Adam Sorkin wrote:
>
> > I can runBraidin gap_console() inside of Sage. Trying to run it in
> > Sage proper gives gives the following run-time error:
>
> > sage:gap.eval('Read("assemble.g")')
> > ''
> > sage: g=SymmetricGroup(3)
> > sage: t=[(2,1),(2,1),(2,1),(2,1)]
> > sage:gap.eval("Braid(g,t)")
>
> Gapand Sage each have their own environments. TheBraidpackage lives  
> entirely insideGap, and can't be directly called with things in the  
> Sage environment, Sage can just askGapto do things in theGap 
> environment. What you can do is
>
> sage: g=SymmetricGroup(3)
> sage: t=[(2,1),(2,1),(2,1),(2,1)]
> sage:gap.eval("Braid(%s,%s)" %gap(g),gap(t))
>
> Even easier, you can do
>
> sage:gap.Braid(g, t)
>
> which will create copies of g and t in thegapenvironment, callgap's Braid() on them, then return the result.
>
> - Robert

Robert Bradshaw

unread,
Nov 9, 2009, 1:08:40 PM11/9/09
to sage-s...@googlegroups.com
On Nov 9, 2009, at 8:58 AM, Adam Sorkin wrote:

>
> I'd like to do it this way, running everything through sage, but it
> doesn't work. Here is what I'm getting:
>
> sage: g = SymmetricGroup(3)
> sage: t = [(2,1),(2,1)]
> sage: gap.Braid(g,t)
> ---------------------------------------------------------------------------

> RuntimeError: Gap produced error output


> Error, no 1st choice method found for `IsConjugate' on 3 arguments
>
> executing Braid($sage9,$sage16);

Hmm... Not sure about this. I'm guessing t is not the right thing.

> I get a different error using
> gap.eval("Braid(%s,%s)" % gap(g), gap(t))
>
> Specifically,
>
> sage: gap.eval("Braid(%s,%s)" % gap(g), gap(t) )
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call
> last)
>
> /Users/adamsorkin/Desktop/braid_dir/<ipython console> in <module>()
>
> TypeError: not enough arguments for format string
>
>
> Perhaps this one is easier to fix.

Yes, that should be

sage: gap.eval("Braid(%s,%s)" % (gap(g), gap(t)) )

But will probably give the same error. Is this what t is supposed to
be in GAP?

sage: t = [(2,1),(2,1)]
sage: gap(t)
[ [ 2, 1 ], [ 2, 1 ] ]

Or did you want something like

sage: sage: g = SymmetricGroup(3)
sage: t = [g((2,1)), g((3,1))] # let t be a list of group elements
(not a list of tuples)
sage: gap(t)
[ (1,2), (1,3) ]
sage: gap.Braid(g,t) # this is more likely to work

Sorry this is so rough around the edges. Usually what happens is
someone wraps the functionality nicely, so all this happens behind the
scenes and it "just works," but that obviously hasn't happened for the
Braids package.

- Robert

Reply all
Reply to author
Forward
0 new messages