#6424: One can no longer convert I=sqrt(-1) to sympy
-----------------------+----------------------------------------------------
 Reporter:  drkirkby   |       Owner:  tbd       
     Type:  defect     |      Status:  new       
 Priority:  major      |   Milestone:  sage-4.1.1
Component:  symbolics  |    Keywords:            
 Reviewer:             |      Author:            
   Merged:             |  
-----------------------+----------------------------------------------------

Comment(by mvngu):

 From this [http://groups.google.com/group/sage-
 devel/browse_thread/thread/c484e5ccbc884998  sage-devel] thread by Ondrej
 Certik:

 Currently this fails:

 sage: sympy.test("sympy/test_external/")
 ============================= test process starts
 ==============================
 executable:
 /home/ondrej/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/bin/sage.bin
  (2.6.2-final-0)

 sympy/test_external/test_codegen_c_cc.py[5] .....
 [OK]
 sympy/test_external/test_numpy.py[19] ...................
 [OK]
 sympy/test_external/test_sage.py[13] .E...........
 [FAIL]
 [...]
  File
 
"/home/ondrej/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6
 /site-packages/sympy/core/sympify.py",
 line 194, in _sympify
    raise SympifyError("%r is NOT a valid SymPy expression" % (a,))
 SympifyError: SympifyError: I is NOT a valid SymPy expression

 =========== tests finished: 36 passed, 1 exceptions in 3.26 seconds
 ============
 DO *NOT* COMMIT!
 False


 This patch fixes it:

 diff -r ca1f31d6f6bf sage/symbolic/expression_conversions.py
 --- a/sage/symbolic/expression_conversions.py   Thu Jul 09 15:14:36 2009
 -0700
 +++ b/sage/symbolic/expression_conversions.py   Mon Jul 13 16:57:22 2009
 -0700
 @@ -572,7 +572,7 @@
         """
         import sympy
         operator = arithmetic_operators[operator]
 -        ops = [self(a) for a in ex.operands()]
 +        ops = [sympy.sympify(self(a)) for a in ex.operands()]
         if operator == "+":
             return sympy.Add(*ops)
         elif operator == "*":

 Now:

 sage: sympy.test("sympy/test_external/")
 ============================= test process starts
 ==============================
 executable:
 /home/ondrej/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/bin/sage.bin
  (2.6.2-final-0)

 sympy/test_external/test_codegen_c_cc.py[5] .....
 [OK]
 sympy/test_external/test_numpy.py[19] ...................
 [OK]
 sympy/test_external/test_sage.py[13] .............
 [OK]

 ================== tests finished: 37 passed in 2.29 seconds
 ===================
 True


 I vaguely remember William run into this bug recently. It was caused
 by switching to the new symbolic, the problem was that passing things
 directly to Mul classes in sympy goes in the fast track and only
 sympifies easy things like python ints. For Sage integers, a full
 sympify must be called, which is what my patch does. The core of the
 problem is in fact in sympy cache mechanism, which only does fast
 track sympify for performance reasons, so the proper fix is to fix our
 cache, which is exactly what we plan to do --- get rid of it,
 hopefully by the end of the summer.

 We are about to release a new sympy now, so the above patch makes all
 sympy 0.6.6 tests pass.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6424#comment:2>
Sage <http://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=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to