Author: mattip <[email protected]>
Branch:
Changeset: r57993:3157376a59f8
Date: 2012-10-10 23:47 +0200
http://bitbucket.org/pypy/pypy/changeset/3157376a59f8/
Log: remove TypeError, add failing test (missing res_type rule
coerce_float for real, imag, abs)
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
@@ -43,9 +43,6 @@
self.imag = imag
def convert_to(self, dtype):
- from pypy.module.micronumpy.types import ComplexFloating
- if not isinstance(dtype.itemtype, ComplexFloating):
- raise TypeError('cannot convert %r to complex' % dtype)
return dtype.box_complex(self.real, self.imag)
def convert_real_to(self, dtype):
@@ -77,12 +74,7 @@
return space.wrap(box.value)
def descr_float(self, space):
- try:
- box = self.convert_to(W_Float64Box._get_dtype(space))
- except TypeError:
- raise OperationError(space.w_TypeError,
- space.wrap("Cannot convert %s to float" %
self._get_dtype(space).name))
-
+ box = self.convert_to(W_Float64Box._get_dtype(space))
assert isinstance(box, W_Float64Box)
return space.wrap(box.value)
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
@@ -468,13 +468,16 @@
assert c[i] == max(a[i], b[i])
def test_basic(self):
- from _numpypy import (complex128, complex64, add,
+ from _numpypy import (complex128, complex64, add, array, dtype,
subtract as sub, multiply, divide, negative, abs, floor_divide,
- reciprocal, real, imag, sign)
+ real, imag, sign)
from _numpypy import (equal, not_equal, greater, greater_equal, less,
less_equal, isnan)
assert real(4.0) == 4.0
assert imag(0.0) == 0.0
+ a = array([complex(3.0, 4.0)])
+ b = a.real
+ assert b.dtype == dtype(float)
for complex_ in complex64, complex128:
O = complex(0, 0)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit