Skip to content

Commit

Permalink
Fix ticket numpy#1058. Thanks to Russel.
Browse files Browse the repository at this point in the history
  • Loading branch information
charris committed Mar 27, 2009
1 parent da8312a commit 94b57c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/src/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7151,7 +7151,7 @@ PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, intp count)
50% overallocation => 0, 4, 8, 14, 23, 36, 56, 86 ...
*/
elcount = (i >> 1) + (i < 4 ? 4 : 2) + i;
if (elcount <= (intp)((~(size_t)0) / elsize)) {
if (elcount <= NPY_MAX_INTP/elsize) {
new_data = PyDataMem_RENEW(ret->data, elcount * elsize);
}
else {
Expand Down
7 changes: 7 additions & 0 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,5 +1275,12 @@ def test_huge_arange(self):
except Exception, e:
self.fail("Got exception of type %s instead of ValueError" % type(e))

def test_fromiter_bytes(self, level=rlevel):
"""Ticket #1058"""
a = np.fromiter(range(10), dtype='b')
b = np.fromiter(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()

0 comments on commit 94b57c7

Please sign in to comment.