[Numpy-svn] r5718 - in trunk/numpy/core: . tests

numpy-svn@scip... numpy-svn@scip...
Thu Aug 28 17:53:12 CDT 2008


Author: charris
Date: 2008-08-28 17:53:06 -0500 (Thu, 28 Aug 2008)
New Revision: 5718

Modified:
   trunk/numpy/core/numeric.py
   trunk/numpy/core/tests/test_regression.py
Log:
Change convolve to raise ValueError on runtime error instead of relying on
assert. The latter fails when run with python -OO.


Modified: trunk/numpy/core/numeric.py
===================================================================
--- trunk/numpy/core/numeric.py	2008-08-27 21:49:40 UTC (rev 5717)
+++ trunk/numpy/core/numeric.py	2008-08-28 22:53:06 UTC (rev 5718)
@@ -571,13 +571,15 @@
     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

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2008-08-27 21:49:40 UTC (rev 5717)
+++ trunk/numpy/core/tests/test_regression.py	2008-08-28 22:53:06 UTC (rev 5718)
@@ -623,8 +623,8 @@
 
     def test_convolve_empty(self, level=rlevel):
         """Convolve should raise an error for empty input array."""
-        self.failUnlessRaises(AssertionError,np.convolve,[],[1])
-        self.failUnlessRaises(AssertionError,np.convolve,[1],[])
+        self.failUnlessRaises(ValueError,np.convolve,[],[1])
+        self.failUnlessRaises(ValueError,np.convolve,[1],[])
 
     def test_multidim_byteswap(self, level=rlevel):
         """Ticket #449"""



More information about the Numpy-svn mailing list