From e4656b563cd33e50983635c5dcc79a7d4e5aedc5 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 28 Aug 2008 22:53:06 +0000 Subject: Change convolve to raise ValueError on runtime error instead of relying on assert. The latter fails when run with python -OO. --- numpy/core/numeric.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'numpy/core/numeric.py') diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 449754f87..96fc1ada0 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -571,13 +571,15 @@ def convolve(a,v,mode='full'): array([ 2.5]) """ - a,v = array(a,ndmin=1),array(v,ndmin=1) + a,v = array(a, ndmin=1),array(v, ndmin=1) if (len(v) > len(a)): a, v = v, a - assert len(a) > 0, 'a cannot be empty' - assert len(v) > 0, 'v cannot be empty' + if len(a) == 0 : + raise ValueError('a cannot be empty') + if len(v) == 0 : + raise ValueError('v cannot be empty') mode = _mode_from_name(mode) - return multiarray.correlate(a,asarray(v)[::-1],mode) + return multiarray.correlate(a, v[::-1], mode) inner = multiarray.inner dot = multiarray.dot -- cgit v1.2.1