Fix complex return values
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 28 Oct 2009 16:10:12 +0000 (17:10 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 28 Oct 2009 16:10:12 +0000 (17:10 +0100)
Cython/Compiler/PyrexTypes.py
tests/run/complex_numbers_T305.pyx

index 3fc3e2151d2c8473e9d04477b082097d1d76a40c..5c2e83fa49f4e2b18ecd115c726226b38c4d5f45 100644 (file)
@@ -875,6 +875,7 @@ class CComplexType(CNumericType):
         CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed)
         self.binops = {}
         self.from_parts = "%s_from_parts" % self.specalization_name()
+        self.default_value = "%s(0, 0)" % self.from_parts
     
     def __eq__(self, other):
         if isinstance(self, CComplexType) and isinstance(other, CComplexType):
index 6f0ac0c061b5a5e80c6842bd034648e67006ecbb..addc91dbe55b3bee24f9f1dcbf705ca34e9854a3 100644 (file)
@@ -66,6 +66,9 @@ __doc__ = u"""
 
     >>> test_coerce_typedef_multiply(3, 1j)
     (3j)
+
+    >>> complex_retval()
+    1j
     
 """
 
@@ -128,3 +131,6 @@ def test_conjugate_typedef(cdouble z):
 ctypedef double mydouble
 def test_coerce_typedef_multiply(mydouble x, double complex z):
     return x * z
+
+cpdef double complex complex_retval():
+    return 1j