Author: Matti Picus <[email protected]>
Branch:
Changeset: r61005:dcb190707bf8
Date: 2013-02-09 18:22 +0200
http://bitbucket.org/pypy/pypy/changeset/dcb190707bf8/
Log: test,fix complex to_builtin_type with ztranslation
diff --git a/pypy/module/micronumpy/test/test_dtypes.py
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -472,6 +472,7 @@
assert numpy.float64(2.0) == 2.0
assert numpy.float64('23.4') == numpy.float64(23.4)
raises(ValueError, numpy.float64, '23.2df')
+ assert "{:g}".format(numpy.complex(0.5+1.5j)) ==
'{:g}'.format(0.5+1.5j)
def test_longfloat(self):
import _numpypy as numpy
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
@@ -1030,6 +1030,14 @@
def for_computation(v):
return float(v[0]), float(v[1])
+ @raw_unary_op
+ def _to_builtin_type(self, v):
+ return v
+
+ def to_builtin_type(self, space, box):
+ real,imag = self.for_computation(self.unbox(box))
+ return space.newcomplex(real, imag)
+
def read_bool(self, arr, i, offset):
v = self.for_computation(self._read(arr.storage, i, offset))
return bool(v[0]) or bool(v[1])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit