Author: mattip <[email protected]>
Branch: numpypy-complex2
Changeset: r57745:aa838974e5f4
Date: 2012-10-02 08:59 +0200
http://bitbucket.org/pypy/pypy/changeset/aa838974e5f4/
Log: test, implement square
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
@@ -287,6 +287,11 @@
complex(float('nan'), 0)], dtype=complex)) == \
[False, True, True, False, False]).all()
+
+ def test_square(self):
+ from _numpypy import square
+ assert square(complex(3, 4)) == complex(3,4) * complex(3, 4)
+
def test_power_complex(self):
inf = float('inf')
ninf = -float('inf')
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
@@ -1380,32 +1380,14 @@
return (math.copysign(rfloat.INFINITY, v[0]),
math.copysign(0., v[1]))
return rcomplex.c_atanh(*v)
-
-
@complex_unary_op
def sqrt(self, v):
return rcomplex.c_sqrt(*v)
- @simple_unary_op
+ @complex_unary_op
def square(self, v):
- return v*v
-
- @raw_unary_op
- def isnan(self, v):
- return rfloat.isnan(v[0]) or rfloat.isnan(v[1])
-
- @raw_unary_op
- def isinf(self, v):
- return rfloat.isinf(v[0]) or rfloat.isinf(v[1])
-
- #@raw_unary_op
- #def isneginf(self, v):
- # return rfloat.isinf(v) and v < 0
-
- #@raw_unary_op
- #def isposinf(self, v):
- # return rfloat.isinf(v) and v > 0
+ return rcomplex.c_mul(v,v)
@raw_unary_op
def isfinite(self, v):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit