Author: mattip <[email protected]>
Branch: numpypy-complex2
Changeset: r56857:36f68c51a23d
Date: 2012-08-26 01:39 +0300
http://bitbucket.org/pypy/pypy/changeset/36f68c51a23d/
Log: silly fixes, returning a wrap(box) instead of wrap(box.value) seems
to work
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
@@ -37,7 +37,7 @@
class ComplexBox(object):
_mixin_ = True
- def __init__(self, real, imag):
+ def __init__(self, real, imag=0.):
self.real = real
self.imag = imag
@@ -292,23 +292,23 @@
class W_Complex64Box(ComplexBox, W_ComplexFloatingBox):
descr__new__, _get_dtype = new_dtype_getter("complex64")
- _COMPONENTS_BOX = W_Float64Box
+ _COMPONENTS_BOX = W_Float32Box
def descr_get_real(self, space):
dtype = self._COMPONENTS_BOX._get_dtype(space)
box = self.convert_real_to(dtype)
assert isinstance(box, self._COMPONENTS_BOX)
- return space.wrap(box.value)
+ return space.wrap(box)
def descr_get_imag(self, space):
dtype = self._COMPONENTS_BOX._get_dtype(space)
box = self.convert_imag_to(dtype)
assert isinstance(box, self._COMPONENTS_BOX)
- return space.wrap(box.value)
+ return space.wrap(box)
class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
descr__new__, _get_dtype = new_dtype_getter("complex128")
- _COMPONENTS_BOX = W_Float32Box
+ _COMPONENTS_BOX = W_Float64Box
def descr_get_real(self, space):
dtype = self._COMPONENTS_BOX._get_dtype(space)
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
@@ -449,7 +449,8 @@
real, imag, should = (1e100, 3e66, '(1e+100+3e+66j)')
c128 = numpy.complex128(complex(real, imag))
- assert type(c128.real) is type(c128.imag) is numpy.float64
+ assert type(c128.real) is type(c128.imag)
+ assert type(c128.real) is float
assert c128.real == real
assert c128.imag == imag
assert repr(c128) == should
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit