diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c index 96ec0dfd3..ddbef40f8 100644 --- a/scipy/base/src/arrayobject.c +++ b/scipy/base/src/arrayobject.c @@ -5514,8 +5514,6 @@ PyArray_CanCastSafely(int fromtype, int totype) case PyArray_BYTE: case PyArray_SHORT: case PyArray_INT: - case PyArray_LONG: - case PyArray_LONGLONG: if (PyTypeNum_ISINTEGER(totype)) { if (PyTypeNum_ISUNSIGNED(totype)) { return (to->elsize > from->elsize); @@ -5531,11 +5529,26 @@ PyArray_CanCastSafely(int fromtype, int totype) return ((to->elsize >> 1) > from->elsize); } else return totype > fromtype; + case PyArray_LONG: + case PyArray_LONGLONG: + if (PyTypeNum_ISINTEGER(totype)) { + if (PyTypeNum_ISUNSIGNED(totype)) { + return (to->elsize > from->elsize); + } + else { + return (to->elsize >= from->elsize); + } + } + else if (PyTypeNum_ISFLOAT(totype)) { + return (to->elsize >= from->elsize); + } + else if (PyTypeNum_ISCOMPLEX(totype)) { + return ((to->elsize >> 1) >= from->elsize); + } + else return totype > fromtype; case PyArray_UBYTE: case PyArray_USHORT: case PyArray_UINT: - case PyArray_ULONG: - case PyArray_ULONGLONG: if (PyTypeNum_ISINTEGER(totype)) { if (PyTypeNum_ISSIGNED(totype)) { return (to->elsize > from->elsize); @@ -5551,6 +5564,23 @@ PyArray_CanCastSafely(int fromtype, int totype) return ((to->elsize >> 1) > from->elsize); } else return totype > fromtype; + case PyArray_ULONG: + case PyArray_ULONGLONG: + if (PyTypeNum_ISINTEGER(totype)) { + if (PyTypeNum_ISSIGNED(totype)) { + return (to->elsize > from->elsize); + } + else { + return (to->elsize >= from->elsize); + } + } + else if (PyTypeNum_ISFLOAT(totype)) { + return (to->elsize >= from->elsize); + } + else if (PyTypeNum_ISCOMPLEX(totype)) { + return ((to->elsize >> 1) >= from->elsize); + } + else return totype > fromtype; case PyArray_FLOAT: case PyArray_DOUBLE: case PyArray_LONGDOUBLE: diff --git a/scipy/base/src/ufuncobject.c b/scipy/base/src/ufuncobject.c index b0426075c..7109e292b 100644 --- a/scipy/base/src/ufuncobject.c +++ b/scipy/base/src/ufuncobject.c @@ -228,12 +228,8 @@ PyUFunc_g_g(char **args, intp *dimensions, intp *steps, void *func) intp n=dimensions[0]; char *ip1=args[0], *op=args[1]; for(i=0; i mm)) { PyErr_Format(PyExc_IndexError, - "index out-of-bounds (0, %d)", mm); + "index out-of-bounds (0, %d)", (int) mm); return NULL; } ptr++;