forked from pool/python-pythran
40 lines
1.2 KiB
Diff
40 lines
1.2 KiB
Diff
|
From a49dc44076f7068205c22f532975c50cc4c03958 Mon Sep 17 00:00:00 2001
|
||
|
From: Lysandros Nikolaou <lisandrosnik@gmail.com>
|
||
|
Date: Wed, 19 Jul 2023 13:03:41 +0200
|
||
|
Subject: [PATCH] Use npy_creal/npy_cimag from npy_math in from_python::convert
|
||
|
|
||
|
---
|
||
|
pythran/pythonic/types/complex.hpp | 5 +++--
|
||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/pythran/pythonic/types/complex.hpp b/pythran/pythonic/types/complex.hpp
|
||
|
index 9b57f7384..929a3d200 100644
|
||
|
--- a/pythran/pythonic/types/complex.hpp
|
||
|
+++ b/pythran/pythonic/types/complex.hpp
|
||
|
@@ -177,6 +177,7 @@ PYTHONIC_NS_END
|
||
|
#ifdef ENABLE_PYTHON_MODULE
|
||
|
|
||
|
#include "numpy/arrayscalars.h"
|
||
|
+#include "numpy/npy_math.h"
|
||
|
#include "pythonic/python/core.hpp"
|
||
|
|
||
|
PYTHONIC_NS_BEGIN
|
||
|
@@ -228,7 +229,7 @@ inline std::complex<long double>
|
||
|
from_python<std::complex<long double>>::convert(PyObject *obj)
|
||
|
{
|
||
|
auto val = PyArrayScalar_VAL(obj, CLongDouble);
|
||
|
- return {val.real, val.imag};
|
||
|
+ return {npy_creall(val), npy_cimagl(val)};
|
||
|
}
|
||
|
|
||
|
template <>
|
||
|
@@ -243,7 +244,7 @@ inline std::complex<float>
|
||
|
from_python<std::complex<float>>::convert(PyObject *obj)
|
||
|
{
|
||
|
auto val = PyArrayScalar_VAL(obj, CFloat);
|
||
|
- return {val.real, val.imag};
|
||
|
+ return {npy_crealf(val), npy_cimagf(val)};
|
||
|
}
|
||
|
PYTHONIC_NS_END
|
||
|
#endif
|