[Scipy-svn] r4512 - in trunk/scipy/fftpack: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Jul 1 00:58:52 EDT 2008
Author: cdavid
Date: 2008-06-30 23:58:48 -0500 (Mon, 30 Jun 2008)
New Revision: 4512
Modified:
trunk/scipy/fftpack/basic.py
trunk/scipy/fftpack/tests/test_basic.py
Log:
Raise a proper exception instead of assertion when s argument shape is longer than x.shape in fftn.
Modified: trunk/scipy/fftpack/basic.py
===================================================================
--- trunk/scipy/fftpack/basic.py 2008-07-01 04:52:00 UTC (rev 4511)
+++ trunk/scipy/fftpack/basic.py 2008-07-01 04:58:48 UTC (rev 4512)
@@ -227,12 +227,14 @@
""" Internal auxiliary function for fftnd, ifftnd."""
if s is None:
s = x.shape
- s = tuple(s)
- if s!=x.shape:
- assert len(s)<=len(x.shape)
+ else:
+ s = tuple(s)
+ if len(s) > len(x.shape):
+ raise ValueError("s shape cannot be longer than x shape.")
for i in range(-len(s),0):
if x.shape[i]!=s[i]:
x = _fix_shape(x,s[i],i)
+
if axes is None:
return work_function(x,s,direction,overwrite_x=overwrite_x)
Modified: trunk/scipy/fftpack/tests/test_basic.py
===================================================================
--- trunk/scipy/fftpack/tests/test_basic.py 2008-07-01 04:52:00 UTC (rev 4511)
+++ trunk/scipy/fftpack/tests/test_basic.py 2008-07-01 04:58:48 UTC (rev 4512)
@@ -358,7 +358,18 @@
assert_array_almost_equal (y,swapaxes(\
fftn(swapaxes(large_x1,-1,-2)),-1,-2))
+ def test_shape_argument_more(self):
+ # Test that fftn raise a value error exception when s.shape is longer
+ # than x.shape
+ x = zeros((4, 4, 2))
+ try:
+ fx = fftn(x, shape = (8, 8, 2, 1))
+ raise AssertionError("s.shape longer than x.shape succeded, "\
+ "but should not have.")
+ except ValueError:
+ pass
+
class TestIfftn(TestCase):
def test_definition(self):
More information about the Scipy-svn
mailing list