From 5bc8d74a443c571d057d47e373f19cd43b0695b3 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 5 Jul 2014 17:19:14 +0200 Subject: [PATCH 1/2] ENH: increase NPY_MAXARGS to 256 Allows larger numbers of arguments for nditer using functions. This can be helpful for complex boolean expressions used in pytables. Closes gh-4398 --- numpy/core/include/numpy/ndarraytypes.h | 2 +- numpy/core/tests/test_nditer.py | 2 +- numpy/lib/tests/test_function_base.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 21ff8cd1ae89..431c63f8a91e 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -32,7 +32,7 @@ */ #define NPY_MAXDIMS 32 -#define NPY_MAXARGS 32 +#define NPY_MAXARGS 256 /* Used for Converter Functions "O&" code in ParseTuple */ #define NPY_FAIL 0 diff --git a/numpy/core/tests/test_nditer.py b/numpy/core/tests/test_nditer.py index 0055c038b749..a9569d9e105a 100644 --- a/numpy/core/tests/test_nditer.py +++ b/numpy/core/tests/test_nditer.py @@ -686,7 +686,7 @@ def test_iter_flags_errors(): # Not enough operands assert_raises(ValueError, nditer, [], [], []) # Too many operands - assert_raises(ValueError, nditer, [a]*100, [], [['readonly']]*100) + assert_raises(ValueError, nditer, [a]*500, [], [['readonly']]*500) # Bad global flag assert_raises(ValueError, nditer, [a], ['bad flag'], [['readonly']]) # Bad op flag diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index ac677a308dbe..7f3e90ee3f39 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -215,9 +215,9 @@ def test_non_bool_deprecation(self): assert_raises(DeprecationWarning, select, conditions, choices) def test_many_arguments(self): - # This used to be limited by NPY_MAXARGS == 32 - conditions = [np.array([False])] * 100 - choices = [np.array([1])] * 100 + # This used to be limited by NPY_MAXARGS + conditions = [np.array([False])] * 500 + choices = [np.array([1])] * 500 select(conditions, choices) From 828acf92b491f8390b35333d9495463145360e6b Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 5 Jul 2014 18:32:42 +0200 Subject: [PATCH 2/2] DOC: add nditer argument increase to release notes [ci skip] --- doc/release/1.9.0-notes.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/release/1.9.0-notes.rst b/doc/release/1.9.0-notes.rst index e1e958e9de06..90c5c919a141 100644 --- a/doc/release/1.9.0-notes.rst +++ b/doc/release/1.9.0-notes.rst @@ -381,6 +381,12 @@ MaskedArray support for more complicated base classes Built-in assumptions that the baseclass behaved like a plain array are being removed. In particalur, ``repr`` and ``str`` should now work more reliably. +Maximum nditer operands increased to 256 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The maximum number of operands that nditer can handle has been increased from +32 to 256. This allows applications like `numexpr` to work with larger +expressions. + C-API ~~~~~