From 3a2a66e20daf0a3468638eaae1c8036b906fab2a Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Wed, 28 Oct 2009 17:10:12 +0100 Subject: [PATCH] Fix complex return values --- Cython/Compiler/PyrexTypes.py | 1 + tests/run/complex_numbers_T305.pyx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 3fc3e215..5c2e83fa 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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): diff --git a/tests/run/complex_numbers_T305.pyx b/tests/run/complex_numbers_T305.pyx index 6f0ac0c0..addc91db 100644 --- a/tests/run/complex_numbers_T305.pyx +++ b/tests/run/complex_numbers_T305.pyx @@ -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 -- 2.26.2