#7504: Magma booleans don't evaluate correctly in boolean contexts
--------------------------+-------------------------------------------------
   Reporter:  kedlaya     |       Owner:  was                   
       Type:  defect      |      Status:  new                   
   Priority:  major       |   Milestone:                        
  Component:  interfaces  |    Keywords:  magma, boolean context
Work_issues:              |      Author:                        
   Reviewer:              |      Merged:                        
--------------------------+-------------------------------------------------

Comment(by GeorgSWeber):

 In "gap.py", in the "class GapElement(ExpectElement)", there is (lines
 1058 ff):
 {{{
     def bool(self):
         """
         EXAMPLES::

             sage: bool(gap(2))
             True
             sage: gap(0).bool()
             False
             sage: gap('false').bool()
             False
         """
         P = self._check_valid()
         return self != P(0) and repr(self) != 'false'
 }}}
 I didn't check maxima.py, ... but in magma.py, I couldn't find a
 counterpart in the class MagmaElement. My first attempt to add this with
 the obvious minor modifications failed however (so I do not post the
 patch):
 {{{
 sage: magma(True).bool()
 ---------------------------------------------------------------------------
 RuntimeError                              Traceback (most recent call
 last)

 
/Users/georgweber/.sage/temp/susanne_webers_computer.local/15820/_Users_georgweber__sage_init_sage_0.py
 in <module>()

 /Users/Shared/sage/sage-4.2.1/local/lib/python2.6/site-
 packages/sage/interfaces/magma.pyc in bool(self)
    2111         """
    2112         P = self._check_valid()
 -> 2113         return self != P(0) and repr(self) != 'false'
    2114
    2115     def __len__(self):

 /Users/Shared/sage/sage-4.2.1/local/lib/python2.6/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element.__richcmp__
 (sage/structure/element.c:6484)()

 /Users/Shared/sage/sage-4.2.1/local/lib/python2.6/site-
 packages/sage/structure/element.so in
 sage.structure.element.Element._richcmp (sage/structure/element.c:6363)()

 /Users/Shared/sage/sage-4.2.1/local/lib/python2.6/site-
 packages/sage/interfaces/expect.pyc in __cmp__(self, other)
    1521         P = self.parent()
    1522         if P.eval("%s %s %s"%(self.name(), P._equality_symbol(),
 -> 1523                                  other.name())) ==
 P._true_symbol():
    1524             return 0
    1525         elif P.eval("%s %s %s"%(self.name(), P._lessthan_symbol(),
 other.name())) == P._true_symbol():

 /Users/Shared/sage/sage-4.2.1/local/lib/python2.6/site-
 packages/sage/interfaces/magma.pyc in eval(self, x, strip, **kwds)
     478         ans = Expect.eval(self, x, **kwds).replace('\\\n','')
     479         if 'Runtime error' in ans or 'User error' in ans:
 --> 480             raise RuntimeError, "Error evaluating Magma
 code.\nIN:%s\nOUT:%s"%(x, ans)
     481         return ans
     482

 RuntimeError: Error evaluating Magma code.
 IN:_sage_[3] eq _sage_[6];
 OUT:
 >> _sage_[3] eq _sage_[6];
              ^
 Runtime error in 'eq': Bad argument types
 Argument types given: BoolElt, RngIntElt
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7504#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--

You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=.


Reply via email to