> On Sun, Sep 7, 2008 at 4:00 AM, Mike Hansen wrote: >> >> There is a patch up at >> http://trac.sagemath.org/sage_trac/attachment/ticket/4036/trac_4036-2.patch >> which improves conversions between Axiom and Sage. It defaults >> to your unparsed input form if it can't find anything smarter to do. > On Sun, Sep 7, 2008 at 9:46 PM, Bill Page wrote: > Excellent. I have applied this patch to > sage-3.1.2.alpha4-sage.math-only-x86_64-Linux and with fricas-1.0.3 > installed. I tried a few things and so far it seems to work great! > I'll have more time to test it thoroughly in the next 24 hours and let > you know if I find any problems. >
Mike, So far everything is looking good to me in your patch. :-) I wonder if there is still time to get it into the next release of Sage? I have a question about the best way to add some new functionality to the axiom interface. Maybe this is an interface design issue or maybe it is just a Python question ... In Sage we can call the Axiom 'guess' function (written by Martin Rubey) to guess expressions for integer sequences. Eg. sage: g=axiom('guess [1,3,5,7,9]') sage: g n 2 [[function= [[x ]f(x): (x - 2x + 1)f(x) - x - 1= 0],order= 0]] sage: g.type() List Record(function: Expression Integer,order: NonNegativeInteger) ----------- As I understand the code in axiom.py, I can write: sage: g[1] n 2 [function= [[x ]f(x): (x - 2x + 1)f(x) - x - 1= 0],order= 0] to return the first item in the Axiom List because __getitem__ is defined in class AxiomElement. Right? But now I have something of this type: sage: g[1].type() Record(function: Expression Integer,order: NonNegativeInteger) The labels (e.g. 'function' and 'order' above) in an Axiom Record are rather like attributes in Python. In Axiom I can write 'g(1).function' and 'g(1).order' sage: axiom(g.name()+'(1).function') n 2 [[x ]f(x): (x - 2x + 1)f(x) - x - 1= 0] sage: axiom(g.name()+'(1).order') 0 So I thought maybe I could also define def __getattr__(self, attrname): if attrname[:1] == "_": raise AttributeError, attrname if str(self.type()).startswith('Record'): P = self.parent() return P('%s.%s'%(self.name(), attrname)) else: raise AttributeError, attrname in AxiomElement. And then in Sage write more naturally: sage: g[1].function n 2 [[x ]f(x): (x - 2x + 1)f(x) - x - 1= 0] and I get the result I hoped for! :-) But when I write: sage: g[1].order <built-in method order of AxiomElement object at 0x2b30ac8cdaa0> I do not get the expected result of 0. :-( How can I persuade Sage to treat '.order' as a call to __getattr__ ? As far as I understand, 'order' is a method inherited via ExpectElement from RingElement. I do not understand why ExpectElement subclasses RingElement. Why Ring? Anyway, in general I am looking for a convenient and natural way to access elements of Axiom type Record and Union. Regards, Bill Page. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---