This is an automated email from the git hooks/post-receive script. yoh pushed a commit to tag 0.4 in repository python-mne.
commit c15907c224577a4110b1711e4a29e780e13bdf76 Author: Alexandre Gramfort <[email protected]> Date: Sat Nov 12 16:16:37 2011 -0500 ENH : raise warning with n_fft is not a power of 2 --- mne/filter.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mne/filter.py b/mne/filter.py index c21c05c..44dda4f 100644 --- a/mne/filter.py +++ b/mne/filter.py @@ -1,8 +1,33 @@ +import warnings import numpy as np from scipy import signal from scipy.fftpack import fft, ifft +def is_power2(num): + """Test if number is a power of 2 + + Parameters + ---------- + num : int + Number + + Returns + ------- + b : bool + True if is power of 2 + + Example + ------- + >>> is_power2(2 ** 3) + True + >>> is_power2(5) + False + """ + num = int(num) + return num != 0 and ((num & (num - 1)) == 0) + + def _overlap_add_filter(x, h, n_fft=None, zero_phase=True): """ Filter using overlap-add FFTs. @@ -55,6 +80,9 @@ def _overlap_add_filter(x, h, n_fft=None, zero_phase=True): if n_fft <= 0: raise ValueError('n_fft is too short, has to be at least len(h)') + if not is_power2(n_fft): + warnings.warn("FFT length is not a power of 2. Can be slower.") + # Filter in frequency domain h_fft = fft(np.r_[h, np.zeros(n_fft - n_h, dtype=h.dtype)]) -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
