summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-06-01 14:42:23 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-10-17 19:42:40 -0700
commit8ed314e4f1316b6b88c0c197bc6b0eb4e3f332d5 (patch)
tree634a911b7dabfba90a220fddd12463fc974690c5
parente1584ca8998425eb6a13fe957a24502eb0a9da27 (diff)
downloadnumpy-8ed314e4f1316b6b88c0c197bc6b0eb4e3f332d5.tar.gz
MAINT: Make it clear how to remove the deprecation
-rw-r--r--numpy/core/src/multiarray/compiled_base.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index f254022c9..f18ce155e 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -98,7 +98,8 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
{
PyObject *list = NULL, *weight = Py_None, *mlength = NULL;
PyArrayObject *lst = NULL, *ans = NULL, *wts = NULL;
- npy_intp *numbers, *ians, len, mx, mn, ans_size, minlength;
+ npy_intp *numbers, *ians, len, mx, mn, ans_size;
+ npy_intp minlength = 0;
npy_intp i;
double *weights , *dans;
static char *kwlist[] = {"list", "weights", "minlength", NULL};
@@ -114,28 +115,30 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
}
len = PyArray_SIZE(lst);
- if (mlength == NULL) {
- minlength = 0;
- }
- else if (mlength == Py_None) {
+ /*
+ * This if/else if can be removed by changing the argspec to O|On above,
+ * once we retire the deprecation
+ */
+ if (mlength == Py_None) {
/* NumPy 1.14, 2017-06-01 */
if (DEPRECATE("0 should be passed as minlength instead of None; "
"this will error in future.") < 0) {
goto fail;
}
- minlength = 0;
}
- else {
+ else if (mlength != NULL) {
minlength = PyArray_PyIntAsIntp(mlength);
- if (minlength < 0) {
- if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ValueError,
- "minlength must be non-negative");
- }
+ if (error_converting(minlength)) {
goto fail;
}
}
+ if (minlength < 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "minlength must be non-negative");
+ goto fail;
+ }
+
/* handle empty list */
if (len == 0) {
ans = (PyArrayObject *)PyArray_ZEROS(1, &minlength, NPY_INTP, 0);