As of SVN from this morning, fromiter cannot create an array whose dtype
is a byte type
In [1]: np.fromiter(range(10), dtype='b')
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
/Users/baxter/<ipython console> in <module>()
MemoryError: cannot allocate array memory
I am not sure how to include a test whose failure condition is the
raising of an exception, but the patch includes the above test.
Russel
Index: numpy/core/src/multiarraymodule.c
===================================================================
--- numpy/core/src/multiarraymodule.c (revision 5866)
+++ numpy/core/src/multiarraymodule.c (working copy)
@@ -6503,7 +6503,8 @@
PyObject *value;
PyObject *iter = PyObject_GetIter(obj);
PyArrayObject *ret = NULL;
- intp i, elsize, elcount;
+ intp i;
+ uintp elsize, elcount;
char *item, *new_data;
if (iter == NULL) goto done;
Index: numpy/core/tests/test_regression.py
===================================================================
--- numpy/core/tests/test_regression.py (revision 5866)
+++ numpy/core/tests/test_regression.py (working copy)
@@ -1208,5 +1208,11 @@
a = np.array(1)
self.failUnlessRaises(ValueError, lambda x: x.choose([]), a)
+ def test_fromiter_comparison(self, level=rlevel):
+ a = np.fromiter(np.range(10), dtype='b')
+ b = np.fromiter(np.range(10), dtype='B')
+ assert np.alltrue(a == np.array([0,1,2,3,4,5,6,7,8,9]))
+ assert np.alltrue(b == np.array([0,1,2,3,4,5,6,7,8,9]))
+
if __name__ == "__main__":
run_module_suite()
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion