[pypy-commit] pypy python-numpy: more tests

mattip noreply at buildbot.pypy.org
Sat Aug 11 23:03:36 CEST 2012


Author: mattip <matti.picus at gmail.com>
Branch: python-numpy
Changeset: r56708:401cb595cff6
Date: 2012-08-11 23:57 +0300
http://bitbucket.org/pypy/pypy/changeset/401cb595cff6/

Log:	more tests

diff --git a/lib_pypy/numpypy/multiarray/__init__.py b/lib_pypy/numpypy/multiarray/__init__.py
--- a/lib_pypy/numpypy/multiarray/__init__.py
+++ b/lib_pypy/numpypy/multiarray/__init__.py
@@ -72,4 +72,9 @@
             tmp[:i] = retVal[:i]
             retVal = tmp
         retVal[i] = value
+    if i<count:
+        raise ValueError('iterator too short')
     return retVal[:i+1]
+
+def fromfile(_file, dtype=float, count=-1, sep=''):
+    raise ValueError('not implemented yet')
diff --git a/lib_pypy/numpypy/test/test_multiarray.py b/lib_pypy/numpypy/test/test_multiarray.py
--- a/lib_pypy/numpypy/test/test_multiarray.py
+++ b/lib_pypy/numpypy/test/test_multiarray.py
@@ -32,3 +32,8 @@
     b = multiarray.fromiter(iterable, np.dtype(float))
     assert b.dtype == np.dtype(float)
     assert all(b == [0., 1., 4., 9., 16.]) == True
+    iterable = (x*x for x in range(5))
+    raises(ValueError, multiarray.fromiter, iterable, np.dtype(float), 10)
+    iterable = (x*x for x in range(5))
+    b = multiarray.fromiter(iterable, np.dtype(float), 3)
+    assert all(b == [0., 1., 4.]) == True


More information about the pypy-commit mailing list