summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-06-01 12:36:17 +0100
committerEric Wieser <wieser.eric@gmail.com>2017-10-17 19:42:40 -0700
commite1584ca8998425eb6a13fe957a24502eb0a9da27 (patch)
tree5b38577141953f89694da48a80c1e7c3d5c47fb9 /numpy
parent77f9540f277de3e727d696eb5987a0505ed8cdf9 (diff)
downloadnumpy-e1584ca8998425eb6a13fe957a24502eb0a9da27.tar.gz
DEP: 0 should be passed to bincount, not None
Fixes gh-8841
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/compiled_base.c12
-rw-r--r--numpy/core/tests/test_deprecations.py6
2 files changed, 16 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index 36ef1d1c4..f254022c9 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -96,7 +96,7 @@ minmax(const npy_intp *data, npy_intp data_len, npy_intp *mn, npy_intp *mx)
NPY_NO_EXPORT PyObject *
arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
{
- PyObject *list = NULL, *weight = Py_None, *mlength = Py_None;
+ 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 i;
@@ -114,7 +114,15 @@ arr_bincount(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds)
}
len = PyArray_SIZE(lst);
- if (mlength == Py_None) {
+ if (mlength == NULL) {
+ minlength = 0;
+ }
+ else 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 {
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index d7c402b53..1c1851fc7 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -463,5 +463,11 @@ class TestTruthTestingEmptyArrays(_DeprecationTestCase):
self.assert_deprecated(bool, args=(np.zeros((0, 0)),))
+class TestBincount(_DeprecationTestCase):
+ # 2017-06-01, 1.14.0
+ def test_bincount_minlength(self):
+ self.assert_deprecated(lambda: np.bincount([1, 2, 3], minlength=None))
+
+
if __name__ == "__main__":
run_module_suite()