[Numpy-svn] r8084 - in trunk/numpy/lib: src tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Mon Feb 1 23:54:53 EST 2010
Author: cdavid
Date: 2010-02-01 22:54:53 -0600 (Mon, 01 Feb 2010)
New Revision: 8084
Modified:
trunk/numpy/lib/src/_compiled_base.c
trunk/numpy/lib/tests/test_regression.py
Log:
BUG: fix #1387. Raise ValueError for empty input to bincount.
Modified: trunk/numpy/lib/src/_compiled_base.c
===================================================================
--- trunk/numpy/lib/src/_compiled_base.c 2010-02-02 04:54:35 UTC (rev 8083)
+++ trunk/numpy/lib/src/_compiled_base.c 2010-02-02 04:54:53 UTC (rev 8084)
@@ -117,6 +117,11 @@
goto fail;
}
len = PyArray_SIZE(lst);
+ if (len < 1) {
+ PyErr_SetString(PyExc_ValueError,
+ "The first argument cannot be empty.");
+ goto fail;
+ }
numbers = (intp *) PyArray_DATA(lst);
mxi = mxx(numbers, len);
mni = mnx(numbers, len);
Modified: trunk/numpy/lib/tests/test_regression.py
===================================================================
--- trunk/numpy/lib/tests/test_regression.py 2010-02-02 04:54:35 UTC (rev 8083)
+++ trunk/numpy/lib/tests/test_regression.py 2010-02-02 04:54:53 UTC (rev 8084)
@@ -176,6 +176,9 @@
sys.stdout = sys.__stdout__
raise AssertionError("ticket #1243")
+ def test_bincount_empty(self):
+ """Ticket #1387: empty array as input for bincount."""
+ assert_raises(ValueError, lambda : np.bincount(np.array([], dtype=np.intp)))
if __name__ == "__main__":
run_module_suite()
More information about the Numpy-svn
mailing list