Browse files

Added a check (and test) on the fft not being along a zero length axis.

  • Loading branch information...
1 parent 35a5f16 commit d5b6999a78088d501743acb4e928a0c878e42aa3 @hgomersall committed Jun 1, 2012
Showing with 16 additions and 1 deletion.
  1. +5 −1 pyfftw/pyfftw.pyx
  2. +11 −0 test/test_pyfftw_complex.py
View
6 pyfftw/pyfftw.pyx
@@ -599,6 +599,10 @@ cdef class FFTW:
# Now get the axes along which the FFT is *not* taken
_not_axes = np.setdiff1d(np.arange(0,len(self.__input_shape)), _axes)
+
+ if 0 in set(self.__input_shape[_axes]):
+ raise ValueError('The input array should have no zero length'
+ 'axes over which the FFT is to be taken')
# Now we can validate the array shapes
if functions['validator'] == None:
@@ -687,7 +691,7 @@ cdef class FFTW:
self.__direction, self.__flags)
if self.__plan == NULL:
- raise ValueError('The data has an uncaught error that led '+
+ raise RuntimeError('The data has an uncaught error that led '+
'to the planner returning NULL. This is a bug.')
def __init__(self, input_array, output_array, axes=[-1],
View
11 test/test_pyfftw_complex.py
@@ -114,6 +114,17 @@ def test_3d(self):
self.run_validate_fft(a, b, axes, create_array_copies=False)
+ def test_zero_length_fft_axis_fail(self):
+
+ in_shape = (1024, 0)
+ out_shape = in_shape
+
+ axes = (-1,)
+
+ a, b = self.create_test_arrays(in_shape, out_shape)
+
+ self.assertRaises(ValueError, self.run_validate_fft, *(a,b, axes))
+
def test_missized_fail(self):
in_shape = self.input_shapes['2d']
_out_shape = self.output_shapes['2d']

0 comments on commit d5b6999

Please sign in to comment.