diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2020-09-12 09:17:10 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-12 09:17:10 -0600 |
commit | bc6000da993399284d2afd4fcfa1e4c4fe0d408e (patch) | |
tree | 96c805aa53ed8ea8453c2dad91586bac34bd413d /numpy/core | |
parent | 254a1f8932b9529db49f0e9043a5288d86bd899e (diff) | |
parent | 9fc177a2a24550cb539fd3577377f6ffc31cdd7b (diff) | |
download | numpy-bc6000da993399284d2afd4fcfa1e4c4fe0d408e.tar.gz |
Merge pull request #17296 from charris/cleanup-some-pyint_-macros
MAINT: Replace some ``pyint_*`` macros defined in ``npy_3kcompat``.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 6 | ||||
-rw-r--r-- | numpy/core/src/multiarray/_multiarray_tests.c.src | 28 | ||||
-rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 4 | ||||
-rw-r--r-- | numpy/core/src/multiarray/scalartypes.c.src | 14 | ||||
-rw-r--r-- | numpy/core/src/umath/_rational_tests.c.src | 22 | ||||
-rw-r--r-- | numpy/core/src/umath/funcs.inc.src | 4 |
6 files changed, 39 insertions, 39 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 8ef9392d3..dc5c2577a 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -8,12 +8,12 @@ sys.path.insert(0, os.path.dirname(__file__)) import ufunc_docstrings as docstrings sys.path.pop(0) -Zero = "PyInt_FromLong(0)" -One = "PyInt_FromLong(1)" +Zero = "PyLong_FromLong(0)" +One = "PyLong_FromLong(1)" True_ = "(Py_INCREF(Py_True), Py_True)" False_ = "(Py_INCREF(Py_False), Py_False)" None_ = object() -AllOnes = "PyInt_FromLong(-1)" +AllOnes = "PyLong_FromLong(-1)" MinusInfinity = 'PyFloat_FromDouble(-NPY_INFINITY)' ReorderableNone = "(Py_INCREF(Py_None), Py_None)" diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src index fc4b2647a..ea04c82bd 100644 --- a/numpy/core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/core/src/multiarray/_multiarray_tests.c.src @@ -186,7 +186,7 @@ test_neighborhood_iterator(PyObject* NPY_UNUSED(self), PyObject* args) Py_DECREF(bound); goto clean_itx; } - bounds[i] = PyInt_AsLong(bound); + bounds[i] = PyLong_AsSsize_t(bound); Py_DECREF(bound); } @@ -345,7 +345,7 @@ test_neighborhood_iterator_oob(PyObject* NPY_UNUSED(self), PyObject* args) Py_DECREF(bound); goto clean_itx; } - bounds[i] = PyInt_AsLong(bound); + bounds[i] = PyLong_AsSsize_t(bound); Py_DECREF(bound); } @@ -369,7 +369,7 @@ test_neighborhood_iterator_oob(PyObject* NPY_UNUSED(self), PyObject* args) Py_DECREF(bound); goto clean_itx; } - bounds[i] = PyInt_AsLong(bound); + bounds[i] = PyLong_AsSsize_t(bound); Py_DECREF(bound); } @@ -1153,11 +1153,11 @@ array_solve_diophantine(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject } for (j = 0; j < nterms; ++j) { - terms[j].a = (npy_int64)PyInt_AsSsize_t(PyTuple_GET_ITEM(A, j)); + terms[j].a = (npy_int64)PyLong_AsSsize_t(PyTuple_GET_ITEM(A, j)); if (error_converting(terms[j].a)) { goto fail; } - terms[j].ub = (npy_int64)PyInt_AsSsize_t(PyTuple_GET_ITEM(U, j)); + terms[j].ub = (npy_int64)PyLong_AsSsize_t(PyTuple_GET_ITEM(U, j)); if (error_converting(terms[j].ub)) { goto fail; } @@ -1733,8 +1733,8 @@ get_struct_alignments(PyObject *NPY_UNUSED(self), PyObject *args) { /**begin repeat * #N = 1,2,3# */ - alignment = PyInt_FromLong(_ALIGN(struct TestStruct@N@)); - size = PyInt_FromLong(sizeof(struct TestStruct@N@)); + alignment = PyLong_FromLong(_ALIGN(struct TestStruct@N@)); + size = PyLong_FromLong(sizeof(struct TestStruct@N@)); val = PyTuple_Pack(2, alignment, size); Py_DECREF(alignment); Py_DECREF(size); @@ -1950,7 +1950,7 @@ run_byteorder_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_SWAP: return PyUnicode_FromString("NPY_SWAP"); case NPY_IGNORE: return PyUnicode_FromString("NPY_IGNORE"); } - return PyInt_FromLong(byteorder); + return PyLong_FromLong(byteorder); } static PyObject * @@ -1965,7 +1965,7 @@ run_sortkind_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_HEAPSORT: return PyUnicode_FromString("NPY_HEAPSORT"); case NPY_STABLESORT: return PyUnicode_FromString("NPY_STABLESORT"); } - return PyInt_FromLong(kind); + return PyLong_FromLong(kind); } static PyObject * @@ -1978,7 +1978,7 @@ run_selectkind_converter(PyObject* NPY_UNUSED(self), PyObject *args) switch (kind) { case NPY_INTROSELECT: return PyUnicode_FromString("NPY_INTROSELECT"); } - return PyInt_FromLong(kind); + return PyLong_FromLong(kind); } static PyObject * @@ -1992,7 +1992,7 @@ run_searchside_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_SEARCHLEFT: return PyUnicode_FromString("NPY_SEARCHLEFT"); case NPY_SEARCHRIGHT: return PyUnicode_FromString("NPY_SEARCHRIGHT"); } - return PyInt_FromLong(side); + return PyLong_FromLong(side); } static PyObject * @@ -2008,7 +2008,7 @@ run_order_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_FORTRANORDER: return PyUnicode_FromString("NPY_FORTRANORDER"); case NPY_KEEPORDER: return PyUnicode_FromString("NPY_KEEPORDER"); } - return PyInt_FromLong(order); + return PyLong_FromLong(order); } static PyObject * @@ -2023,7 +2023,7 @@ run_clipmode_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_WRAP: return PyUnicode_FromString("NPY_WRAP"); case NPY_RAISE: return PyUnicode_FromString("NPY_RAISE"); } - return PyInt_FromLong(mode); + return PyLong_FromLong(mode); } static PyObject * @@ -2040,7 +2040,7 @@ run_casting_converter(PyObject* NPY_UNUSED(self), PyObject *args) case NPY_SAME_KIND_CASTING: return PyUnicode_FromString("NPY_SAME_KIND_CASTING"); case NPY_UNSAFE_CASTING: return PyUnicode_FromString("NPY_UNSAFE_CASTING"); } - return PyInt_FromLong(casting); + return PyLong_FromLong(casting); } static PyObject * diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index fa0b94d09..ecaca72a1 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -175,7 +175,7 @@ MyPyLong_AsUnsigned@Type@ (PyObject *obj) * * #TYPE = BOOL, BYTE, UBYTE, SHORT, USHORT, INT, LONG, UINT, ULONG, * LONGLONG, ULONGLONG, HALF, FLOAT, DOUBLE# - * #func1 = PyBool_FromLong, PyInt_FromLong*6, PyLong_FromUnsignedLong*2, + * #func1 = PyBool_FromLong, PyLong_FromLong*6, PyLong_FromUnsignedLong*2, * PyLong_FromLongLong, PyLong_FromUnsignedLongLong, * MyPyFloat_FromHalf, PyFloat_FromDouble*2# * #func2 = PyObject_IsTrue, MyPyLong_AsLong*6, MyPyLong_AsUnsignedLong*2, @@ -4461,7 +4461,7 @@ set_typeinfo(PyObject *dict) return -1; } } - key = PyInt_FromLong(NPY_@name2@); + key = PyLong_FromLong(NPY_@name2@); if (key == NULL) { return -1; } diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 1eb226624..d0efaa2a0 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1058,7 +1058,7 @@ gentype_richcompare(PyObject *self, PyObject *other, int cmp_op) static PyObject * gentype_ndim_get(PyObject *NPY_UNUSED(self)) { - return PyInt_FromLong(0); + return PyLong_FromLong(0); } static PyObject * @@ -1099,7 +1099,7 @@ inttype_numerator_get(PyObject *self) static PyObject * inttype_denominator_get(PyObject *self) { - return PyInt_FromLong(1); + return PyLong_FromLong(1); } @@ -1119,7 +1119,7 @@ gentype_itemsize_get(PyObject *self) typecode = PyArray_DescrFromScalar(self); elsize = typecode->elsize; - ret = PyInt_FromLong((long) elsize); + ret = PyLong_FromLong((long) elsize); Py_DECREF(typecode); return ret; } @@ -1127,7 +1127,7 @@ gentype_itemsize_get(PyObject *self) static PyObject * gentype_size_get(PyObject *NPY_UNUSED(self)) { - return PyInt_FromLong(1); + return PyLong_FromLong(1); } static PyObject * @@ -1311,7 +1311,7 @@ gentype_imag_get(PyObject *self) ret = PyObject_GetAttrString(obj, "imag"); if (ret == NULL) { PyErr_Clear(); - obj = PyInt_FromLong(0); + obj = PyLong_FromLong(0); newtype = PyArray_DescrFromType(NPY_OBJECT); ret = PyArray_Scalar((char *)&obj, newtype, NULL); Py_DECREF(newtype); @@ -2897,7 +2897,7 @@ bool_arrtype_nonzero(PyObject *a) * ulong, ulonglong# * #Name = Byte, Short, Int, Long, UByte, UShort, LongLong, UInt, * ULong, ULongLong# - * #type = PyInt_FromLong*6, PyLong_FromLongLong*1, + * #type = PyLong_FromLong*6, PyLong_FromLongLong*1, * PyLong_FromUnsignedLong*2, PyLong_FromUnsignedLongLong# */ static PyNumberMethods @name@_arrtype_as_number; @@ -2926,7 +2926,7 @@ bool_index(PyObject *a) return NULL; } else { - return PyInt_FromLong(PyArrayScalar_VAL(a, Bool)); + return PyLong_FromLong(PyArrayScalar_VAL(a, Bool)); } } diff --git a/numpy/core/src/umath/_rational_tests.c.src b/numpy/core/src/umath/_rational_tests.c.src index e611a0847..08c259d98 100644 --- a/numpy/core/src/umath/_rational_tests.c.src +++ b/numpy/core/src/umath/_rational_tests.c.src @@ -430,7 +430,7 @@ pyrational_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { PyObject* y; int eq; x[i] = PyTuple_GET_ITEM(args, i); - n[i] = PyInt_AsLong(x[i]); + n[i] = PyLong_AsLong(x[i]); if (error_converting(n[i])) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { PyErr_Format(PyExc_TypeError, @@ -441,7 +441,7 @@ pyrational_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { return 0; } /* Check that we had an exact integer */ - y = PyInt_FromLong(n[i]); + y = PyLong_FromLong(n[i]); if (!y) { return 0; } @@ -478,7 +478,7 @@ pyrational_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { else { \ PyObject* y_; \ int eq_; \ - long n_ = PyInt_AsLong(object); \ + long n_ = PyLong_AsLong(object); \ if (error_converting(n_)) { \ if (PyErr_ExceptionMatches(PyExc_TypeError)) { \ PyErr_Clear(); \ @@ -487,7 +487,7 @@ pyrational_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { } \ return 0; \ } \ - y_ = PyInt_FromLong(n_); \ + y_ = PyLong_FromLong(n_); \ if (!y_) { \ return 0; \ } \ @@ -591,7 +591,7 @@ RATIONAL_BINOP_2(floor_divide, } RATIONAL_UNOP(negative,rational,rational_negative(x),PyRational_FromRational) RATIONAL_UNOP(absolute,rational,rational_abs(x),PyRational_FromRational) -RATIONAL_UNOP(int,long,rational_int(x),PyInt_FromLong) +RATIONAL_UNOP(int,long,rational_int(x),PyLong_FromLong) RATIONAL_UNOP(float,double,rational_double(x),PyFloat_FromDouble) static PyObject* @@ -647,12 +647,12 @@ static PyNumberMethods pyrational_as_number = { static PyObject* pyrational_n(PyObject* self, void* closure) { - return PyInt_FromLong(((PyRational*)self)->r.n); + return PyLong_FromLong(((PyRational*)self)->r.n); } static PyObject* pyrational_d(PyObject* self, void* closure) { - return PyInt_FromLong(d(((PyRational*)self)->r)); + return PyLong_FromLong(d(((PyRational*)self)->r)); } static PyGetSetDef pyrational_getset[] = { @@ -727,17 +727,17 @@ npyrational_setitem(PyObject* item, void* data, void* arr) { r = ((PyRational*)item)->r; } else { - long n = PyInt_AsLong(item); + long long n = PyLong_AsLongLong(item); PyObject* y; int eq; if (error_converting(n)) { return -1; } - y = PyInt_FromLong(n); + y = PyLong_FromLongLong(n); if (!y) { return -1; } - eq = PyObject_RichCompareBool(item,y,Py_EQ); + eq = PyObject_RichCompareBool(item, y, Py_EQ); Py_DECREF(y); if (eq<0) { return -1; @@ -749,7 +749,7 @@ npyrational_setitem(PyObject* item, void* data, void* arr) { } r = make_rational_int(n); } - memcpy(data,&r,sizeof(rational)); + memcpy(data, &r, sizeof(rational)); return 0; } diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src index 273779ee8..9b04dc779 100644 --- a/numpy/core/src/umath/funcs.inc.src +++ b/numpy/core/src/umath/funcs.inc.src @@ -26,13 +26,13 @@ Py_square(PyObject *o) static PyObject * Py_get_one(PyObject *NPY_UNUSED(o)) { - return PyInt_FromLong(1); + return PyLong_FromLong(1); } static PyObject * Py_reciprocal(PyObject *o) { - PyObject *one = PyInt_FromLong(1); + PyObject *one = PyLong_FromLong(1); PyObject *result; if (!one) { |