Author: mattip <[email protected]>
Branch: numpypy-complex2
Changeset: r57194:d4fe1f554cae
Date: 2012-09-06 22:55 +0300
http://bitbucket.org/pypy/pypy/changeset/d4fe1f554cae/
Log: finish complex128 basic ufuncs, complex64 ufuncs need space support
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
@@ -298,13 +298,13 @@
dtype = self._COMPONENTS_BOX._get_dtype(space)
box = self.convert_real_to(dtype)
assert isinstance(box, self._COMPONENTS_BOX)
- return space.wrap(box)
+ return space.wrap(box.value)
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)
+ return space.wrap(box.value)
class W_Complex128Box(ComplexBox, W_ComplexFloatingBox):
descr__new__, _get_dtype = new_dtype_getter("complex128")
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -1021,7 +1021,7 @@
)
tested_funcs=[]
fail_at_end = False
- for complex_, abs_err in ((np.complex128, 5e-323), (np.complex64,
5e-32)):
+ for complex_, abs_err in ((np.complex64, 5e-32), (np.complex128,
5e-323), ):
for id, fn, ar, ai, er, ei, flags in parse_testfile(testcases):
arg = complex_(complex(ar, ai))
expected = (er, ei)
@@ -1031,6 +1031,8 @@
fn = 'arc' + fn[1:]
elif fn.startswith('atan'):
fn = 'arc' + fn[1:]
+ elif fn in ('rect', 'polar'):
+ continue
function = getattr(np, fn)
_actual = function(arg)
actual = (_actual.real, _actual.imag)
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
@@ -1223,24 +1223,28 @@
@complex_unary_op
def sin(self, v):
if math.isinf(v[0]):
+ if v[1] == 0.:
+ return rfloat.NAN, 0.
if isfinite(v[1]):
+ return rfloat.NAN, rfloat.NAN
+ elif not math.isnan(v[1]):
return rfloat.NAN, rfloat.INFINITY
- elif not math.isnan(v[1]):
- return rfloat.INFINITY, rfloat.NAN
return rcomplex.c_sin(*v)
@complex_unary_op
def cos(self, v):
if math.isinf(v[0]):
+ if v[1] == 0.:
+ return rfloat.NAN, 0.0
if isfinite(v[1]):
- return rfloat.NAN, 0.0
+ return rfloat.NAN, rfloat.NAN
elif not math.isnan(v[1]):
return rfloat.INFINITY, rfloat.NAN
return rcomplex.c_cos(*v)
@complex_unary_op
def tan(self, v):
- if isinf(v[0]) and isfinite(v[1]):
+ if math.isinf(v[0]) and isfinite(v[1]):
return rfloat.NAN, rfloat.NAN
return rcomplex.c_tan(*v)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit