#5047: [with patch, positive review pending changes] comparing complex i raises
error
------------------------------+---------------------------------------------
 Reporter:  burcin            |        Owner:  somebody
     Type:  defect            |       Status:  new     
 Priority:  major             |    Milestone:  sage-3.3
Component:  basic arithmetic  |   Resolution:          
 Keywords:                    |  
------------------------------+---------------------------------------------
Comment (by SimonKing):

 The second patch `cmp_doc.patch` (to be applied after the first patch)
 adds more documentation.

 Replying to [comment:3 burcin]:
 > I ran into this when testing new printing code in pynac. ATM, pynac uses
 the sign function, which is defined to be cmp(x, 0), to determine if it
 should print a minus sign. Thus, we have the following:
 >
 > {{{
 > sage: var('x',ns=1)
 > sage: i*x
 > <boom>
 > }}}

 Ok, but I think there should be a different approach for determining the
 sign when printing an imaginary number.
 However, personally I believe that `sign(I)` should raise an error.

 > I somehow thought that the cmp function was not supposed to raise
 exceptions, but googling shortly didn't turn up any evidence to support
 this argument.

 ... and, as I mentioned above, `cmp` does raise an exception in Python.

 > BTW, the sign function is also mentioned here: #777

 The `sign` function defined in #777 would simply return 0 on non-real
 constants, because it tests `bool(x > 0)`. Indeed, we have
 {{{
 sage: bool(I > 0)
 False
 sage: bool(I < 0)
 False
 }}}
 so, at least it does not go boom (which it ''should'', though!).

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5047#comment:4>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to