Ask Your Question
2

gap record

asked 2015-01-05 23:43:53 +0100

vdelecroix gravatar image

updated 2015-06-30 08:56:59 +0100

Hello,

I would like to manipulate gap records (association name -> value) through sage... but it does not seem available. Here is a sample from GAP

gap> rec( a := 1, b := "deux" );
rec( a := 1, b := "deux" )
gap> r.a;
1
gap> r.b;
"deux"

But in Sage

sage: w = gap('rec( a := 1, b := "deux" );')
sage: w
rec(
  a := 1,
  b := "deux" )
sage: w.a
a
sage: w.b
b

Which is very strange!! Hopefully, it is still possible to do

sage: gap("{}.a".format(w._name))
1
sage: gap("{}.b".format(w._name))
deux

Is there a better way to deal with them?

Thanks Vincent

edit retag flag offensive close merge delete

Comments

GAP 4.7.7 (February 2015) fixed a bug where recursive records might be printed with the wrong component name, coming from component names being ordered differently in two different pieces of code (see here). Could this be related? Is this reproducible with GAP 4.7.7 or 4.7.8?

alexander konovalov gravatar imagealexander konovalov ( 2015-06-24 12:13:51 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-30 14:16:07 +0100

nbruin gravatar image

It looks like you can do it via the libgap library interface:

sage: w = libgap.eval('rec( a := 1, b := "deux" );')
sage: w['a']
1
sage: w['b']
"deux"
sage: w2 = libgap({'a':1,'b':'deux'})
sage: w == w2
True

(note that gap records are quite like associative arrays, so letting them correspond to python dicts seems a reasonable interface design. It doesn't look like this mapping was taken into consideration in the pexpect based interface)

edit flag offensive delete link more

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: 2015-01-05 23:43:53 +0100

Seen: 783 times

Last updated: Jun 30 '15