Author: Mike Blume <[email protected]>
Branch:
Changeset: r53354:f465de885986
Date: 2012-03-12 13:23 -0700
http://bitbucket.org/pypy/pypy/changeset/f465de885986/
Log: failing tests for __floordiv__ operation
mostly copying these from the __div__ tests
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -625,6 +625,54 @@
for i in range(5):
assert b[i] == i / 5.0
+ def test_floordiv(self):
+ from math import isnan
+ from _numpypy import array, dtype
+
+ a = array(range(1, 6))
+ b = a // a
+ for i in range(5):
+ assert b[i] == 1
+
+ a = array(range(1, 6), dtype=bool)
+ b = a // a
+ assert b.dtype is dtype("int8")
+ for i in range(5):
+ assert b[i] == 1
+
+ a = array([-1, 0, 1])
+ b = array([0, 0, 0])
+ c = a // b
+ assert (c == [0, 0, 0]).all()
+
+ a = array([-1.0, 0.0, 1.0])
+ b = array([0.0, 0.0, 0.0])
+ c = a // b
+ assert c[0] == float('-inf')
+ assert isnan(c[1])
+ assert c[2] == float('inf')
+
+ b = array([-0.0, -0.0, -0.0])
+ c = a // b
+ assert c[0] == float('inf')
+ assert isnan(c[1])
+ assert c[2] == float('-inf')
+
+ def test_floordiv_other(self):
+ from _numpypy import array
+ a = array(range(5))
+ b = array([2, 2, 2, 2, 2], float)
+ c = a // b
+ for i in range(5):
+ assert c[i] == i // 2
+
+ def test_floordiv_constant(self):
+ from _numpypy import array
+ a = array(range(5))
+ b = a // 5
+ for i in range(5):
+ assert b[i] == i // 5
+
def test_truediv(self):
from operator import truediv
from _numpypy import arange
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit