diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-29 10:38:34 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-29 10:38:34 +0000 |
commit | 0245ddea0b3a7ccf8dfc1a8366cbacb2232cefb8 (patch) | |
tree | 1262099e756fae28c5854e99cd71267d8b38f2b2 | |
parent | 2438f98798fa6cf0443433d879365cd2121b6b5e (diff) | |
download | numpy-0245ddea0b3a7ccf8dfc1a8366cbacb2232cefb8.tar.gz |
Fixed so that long integers convert to int64 arrays if possible.
-rw-r--r-- | numpy/core/src/arrayobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 0cc35efc6..049049664 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -5189,6 +5189,15 @@ _array_find_type(PyObject *op, PyArray_Descr *minitype, int max) else if (PyInt_Check(op)) { chktype = PyArray_DescrFromType(PyArray_LONG); goto finish; + } else if (PyLong_Check(op)) { + /* if integer can fit into a longlong then return that + */ + if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) { + PyErr_Clear(); + goto deflt; + } + chktype = PyArray_DescrFromType(PyArray_LONGLONG); + goto finish; } else if (PyFloat_Check(op)) { chktype = PyArray_DescrFromType(PyArray_DOUBLE); goto finish; |