[pypy-commit] pypy numpypy-complex2: add tests, fix for numpy.real, imag
mattip
noreply at buildbot.pypy.org
Tue Sep 25 08:23:28 CEST 2012
Author: mattip <matti.picus at gmail.com>
Branch: numpypy-complex2
Changeset: r57544:595e125b5022
Date: 2012-09-25 08:22 +0200
http://bitbucket.org/pypy/pypy/changeset/595e125b5022/
Log: add tests, fix for numpy.real, imag
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -147,6 +147,8 @@
('floor_divide', 'floor_divide'),
('logaddexp', 'logaddexp'),
('logaddexp2', 'logaddexp2'),
+ ('real', 'real'),
+ ('imag', 'imag'),
]:
interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl
diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -417,10 +417,11 @@
def test_basic(self):
from _numpypy import (complex128, complex64, add,
subtract as sub, multiply, divide, negative, abs,
- reciprocal)
+ reciprocal, real, imag)
from _numpypy import (equal, not_equal, greater, greater_equal, less,
less_equal)
-
+ assert real(4.0) == 4.0
+ assert imag(0.0) == 0.0
for complex_ in complex64, complex128:
O = complex(0, 0)
@@ -479,6 +480,8 @@
# but _numpypy raises a TypeError
raises((TypeError, AttributeError), 'c2.real = 10.')
raises((TypeError, AttributeError), 'c2.imag = 10.')
+ assert(real(c2) == 3.0)
+ assert(imag(c2) == 4.0)
def test_math(self):
if self.isWindows:
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1054,11 +1054,11 @@
@complex_to_real_unary_op
def real(self, v):
- return v.real
+ return v[0]
@complex_to_real_unary_op
def imag(self, v):
- return v.imag
+ return v[1]
@complex_to_real_unary_op
def abs(self, v):
More information about the pypy-commit
mailing list