summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-04-05 01:22:19 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-04-05 01:25:15 +0100
commit7df090a6639be4ab462349106a0b29287bf0fe06 (patch)
treee7557c9782e75d3a71de34e338313a992f89bd39 /numpy
parentc4f1dec9ff47134840109fa719719a73a9ca79be (diff)
downloadnumpy-7df090a6639be4ab462349106a0b29287bf0fe06.tar.gz
MAINT: Use the PyArray_FROM_O macro more
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/arrayobject.c6
-rw-r--r--numpy/core/src/multiarray/compiled_base.c5
-rw-r--r--numpy/core/src/multiarray/datetime_strings.c3
-rw-r--r--numpy/core/src/multiarray/getset.c4
-rw-r--r--numpy/core/src/multiarray/iterators.c2
-rw-r--r--numpy/core/src/multiarray/mapping.c2
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c23
7 files changed, 19 insertions, 26 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index eae9a96a2..8946ff255 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -1362,8 +1362,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
if (PyArray_TYPE(self) == NPY_VOID) {
int _res;
- array_other = (PyArrayObject *)PyArray_FromAny(other, NULL, 0, 0, 0,
- NULL);
+ array_other = (PyArrayObject *)PyArray_FROM_O(other);
/*
* If not successful, indicate that the items cannot be compared
* this way.
@@ -1440,8 +1439,7 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op)
if (PyArray_TYPE(self) == NPY_VOID) {
int _res;
- array_other = (PyArrayObject *)PyArray_FromAny(other, NULL, 0, 0, 0,
- NULL);
+ array_other = (PyArrayObject *)PyArray_FROM_O(other);
/*
* If not successful, indicate that the items cannot be compared
* this way.
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index f6085b368..87a32d150 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -874,7 +874,7 @@ static int sequence_to_arrays(PyObject *seq,
return -1;
}
- op[i] = (PyArrayObject *)PyArray_FromAny(item, NULL, 0, 0, 0, NULL);
+ op[i] = (PyArrayObject *)PyArray_FROM_O(item);
if (op[i] == NULL) {
while (--i >= 0) {
Py_DECREF(op[i]);
@@ -1209,8 +1209,7 @@ arr_unravel_index(PyObject *self, PyObject *args, PyObject *kwds)
unravel_size = PyArray_MultiplyList(dimensions.ptr, dimensions.len);
if (!PyArray_Check(indices0)) {
- indices = (PyArrayObject*)PyArray_FromAny(indices0,
- NULL, 0, 0, 0, NULL);
+ indices = (PyArrayObject*)PyArray_FROM_O(indices0);
if (indices == NULL) {
goto fail;
}
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c
index 4114acae2..716453c95 100644
--- a/numpy/core/src/multiarray/datetime_strings.c
+++ b/numpy/core/src/multiarray/datetime_strings.c
@@ -1364,8 +1364,7 @@ array_datetime_as_string(PyObject *NPY_UNUSED(self), PyObject *args,
/* Claim a reference to timezone for later */
Py_XINCREF(timezone_obj);
- op[0] = (PyArrayObject *)PyArray_FromAny(arr_in,
- NULL, 0, 0, 0, NULL);
+ op[0] = (PyArrayObject *)PyArray_FROM_O(arr_in);
if (op[0] == NULL) {
goto fail;
}
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index a49e56b7f..2fbf15848 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -755,7 +755,7 @@ array_real_set(PyArrayObject *self, PyObject *val)
Py_INCREF(self);
ret = self;
}
- new = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);
+ new = (PyArrayObject *)PyArray_FROM_O(val);
if (new == NULL) {
Py_DECREF(ret);
return -1;
@@ -816,7 +816,7 @@ array_imag_set(PyArrayObject *self, PyObject *val)
if (ret == NULL) {
return -1;
}
- new = (PyArrayObject *)PyArray_FromAny(val, NULL, 0, 0, 0, NULL);
+ new = (PyArrayObject *)PyArray_FROM_O(val);
if (new == NULL) {
Py_DECREF(ret);
return -1;
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
index 50f1cb1f4..8df555fa1 100644
--- a/numpy/core/src/multiarray/iterators.c
+++ b/numpy/core/src/multiarray/iterators.c
@@ -1553,7 +1553,7 @@ arraymultiter_new(PyTypeObject *NPY_UNUSED(subtype), PyObject *args, PyObject *k
}
}
else {
- arr = PyArray_FromAny(obj, NULL, 0, 0, 0, NULL);
+ arr = PyArray_FROM_O(obj);
if (arr == NULL) {
goto fail;
}
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index 7a009d237..302b0ca1c 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -379,7 +379,7 @@ prepare_index(PyArrayObject *self, PyObject *index,
if (!PyArray_Check(obj)) {
PyArrayObject *tmp_arr;
- tmp_arr = (PyArrayObject *)PyArray_FromAny(obj, NULL, 0, 0, 0, NULL);
+ tmp_arr = (PyArrayObject *)PyArray_FROM_O(obj);
if (tmp_arr == NULL) {
/* TODO: Should maybe replace the error here? */
goto failed_building_indices;
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index 2855c70eb..bb63e3e53 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -594,8 +594,7 @@ PyArray_Concatenate(PyObject *op, int axis)
narrays = iarrays;
goto fail;
}
- arrays[iarrays] = (PyArrayObject *)PyArray_FromAny(item, NULL,
- 0, 0, 0, NULL);
+ arrays[iarrays] = (PyArrayObject *)PyArray_FROM_O(item);
Py_DECREF(item);
if (arrays[iarrays] == NULL) {
narrays = iarrays;
@@ -1088,7 +1087,7 @@ PyArray_CopyAndTranspose(PyObject *op)
PyArray_Dims new_axes;
/* Make sure we have an array */
- arr = (PyArrayObject *)PyArray_FromAny(op, NULL, 0, 0, 0, NULL);
+ arr = (PyArrayObject *)PyArray_FROM_O(op);
if (arr == NULL) {
return NULL;
}
@@ -3085,7 +3084,7 @@ PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
PyArrayObject *arr, *ax, *ay;
PyObject *ret = NULL;
- arr = (PyArrayObject *)PyArray_FromAny(condition, NULL, 0, 0, 0, NULL);
+ arr = (PyArrayObject *)PyArray_FROM_O(condition);
if (arr == NULL) {
return NULL;
}
@@ -3101,8 +3100,8 @@ PyArray_Where(PyObject *condition, PyObject *x, PyObject *y)
return NULL;
}
- ax = (PyArrayObject*)PyArray_FromAny(x, NULL, 0, 0, 0 ,NULL);
- ay = (PyArrayObject*)PyArray_FromAny(y, NULL, 0, 0, 0 ,NULL);
+ ax = (PyArrayObject*)PyArray_FROM_O(x);
+ ay = (PyArrayObject*)PyArray_FROM_O(y);
if (ax == NULL || ay == NULL) {
goto fail;
}
@@ -3282,8 +3281,7 @@ array_can_cast_safely(PyObject *NPY_UNUSED(self), PyObject *args,
else if (PyArray_IsScalar(from_obj, Generic) ||
PyArray_IsPythonNumber(from_obj)) {
PyArrayObject *arr;
- arr = (PyArrayObject *)PyArray_FromAny(from_obj,
- NULL, 0, 0, 0, NULL);
+ arr = (PyArrayObject *)PyArray_FROM_O(from_obj);
if (arr == NULL) {
goto finish;
}
@@ -3345,7 +3343,7 @@ array_min_scalar_type(PyObject *NPY_UNUSED(dummy), PyObject *args)
return NULL;
}
- array = (PyArrayObject *)PyArray_FromAny(array_in, NULL, 0, 0, 0, NULL);
+ array = (PyArrayObject *)PyArray_FROM_O(array_in);
if (array == NULL) {
return NULL;
}
@@ -3385,8 +3383,7 @@ array_result_type(PyObject *NPY_UNUSED(dummy), PyObject *args)
}
else if (PyArray_IsScalar(obj, Generic) ||
PyArray_IsPythonNumber(obj)) {
- arr[narr] = (PyArrayObject *)PyArray_FromAny(obj,
- NULL, 0, 0, 0, NULL);
+ arr[narr] = (PyArrayObject *)PyArray_FROM_O(obj);
if (arr[narr] == NULL) {
goto finish;
}
@@ -3997,7 +3994,7 @@ array_shares_memory_impl(PyObject *args, PyObject *kwds, Py_ssize_t default_max_
else {
/* Use FromAny to enable checking overlap for objects exposing array
interfaces etc. */
- self = (PyArrayObject*)PyArray_FromAny(self_obj, NULL, 0, 0, 0, NULL);
+ self = (PyArrayObject*)PyArray_FROM_O(self_obj);
if (self == NULL) {
goto fail;
}
@@ -4008,7 +4005,7 @@ array_shares_memory_impl(PyObject *args, PyObject *kwds, Py_ssize_t default_max_
Py_INCREF(other);
}
else {
- other = (PyArrayObject*)PyArray_FromAny(other_obj, NULL, 0, 0, 0, NULL);
+ other = (PyArrayObject*)PyArray_FROM_O(other_obj);
if (other == NULL) {
goto fail;
}