[pypy-commit] pypy default: np.complex128 doesn't need a __complex__ method, simplify
bdkearns
noreply at buildbot.pypy.org
Mon Nov 4 09:04:16 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r67827:53eec95199ea
Date: 2013-11-04 02:55 -0500
http://bitbucket.org/pypy/pypy/changeset/53eec95199ea/
Log: np.complex128 doesn't need a __complex__ method, simplify
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -339,10 +339,6 @@
descr__new__, _get_dtype, descr_reduce = new_dtype_getter("float64")
class W_ComplexFloatingBox(W_InexactBox):
- def descr_complex(self, space):
- assert isinstance(self, ComplexBox)
- return space.wrap(complex(self.real, self.imag))
-
def descr_get_real(self, space):
dtype = self._COMPONENTS_BOX._get_dtype(space)
box = self.convert_real_to(dtype)
@@ -648,7 +644,7 @@
__module__ = "numpy",
__new__ = interp2app(W_Complex64Box.descr__new__.im_func),
__reduce__ = interp2app(W_Complex64Box.descr_reduce),
- __complex__ = interp2app(W_ComplexFloatingBox.descr_complex),
+ __complex__ = interp2app(W_GenericBox.item),
real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
)
@@ -657,7 +653,6 @@
__module__ = "numpy",
__new__ = interp2app(W_Complex128Box.descr__new__.im_func),
__reduce__ = interp2app(W_Complex128Box.descr_reduce),
- __complex__ = interp2app(W_ComplexFloatingBox.descr_complex),
real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
)
@@ -673,7 +668,7 @@
__module__ = "numpy",
__new__ = interp2app(W_ComplexLongBox.descr__new__.im_func),
__reduce__ = interp2app(W_ComplexLongBox.descr_reduce),
- __complex__ = interp2app(W_ComplexFloatingBox.descr_complex),
+ __complex__ = interp2app(W_GenericBox.item),
real = GetSetProperty(W_ComplexFloatingBox.descr_get_real),
imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
)
diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -68,4 +68,5 @@
import numpy as np
for tp in [np.csingle, np.cdouble, np.clongdouble]:
x = tp(1+2j)
+ assert hasattr(x, '__complex__') == (tp != np.cdouble)
assert complex(x) == 1+2j
More information about the pypy-commit
mailing list