FFT_tools: two spaces before inline comments (PEP8)
authorW. Trevor King <wking@tremily.us>
Sun, 18 Nov 2012 22:27:46 +0000 (17:27 -0500)
committerW. Trevor King <wking@tremily.us>
Sun, 18 Nov 2012 22:27:46 +0000 (17:27 -0500)
FFT_tools.py

index a60777ba9753f2d3e2e4f72baac657431ad3bc82..78c4e29b97c0faef3ebed2fc0b4717d3c3348629 100644 (file)
@@ -201,7 +201,7 @@ def _test_unitary_rfft_rect(
     #_test_unitary_rfft_parsevals(x, samp_freq, freq_axis, X)
 
     # remove the phase due to our time shift
-    j = _numpy.complex(0.0,1.0) # sqrt(-1)
+    j = _numpy.complex(0.0,1.0)  # sqrt(-1)
     for i in range(len(freq_axis)):
         f = freq_axis[i]
         inverse_phase_shift = _numpy.exp(j*2.0*_numpy.pi*time_shift*f)
@@ -255,7 +255,7 @@ def _test_unitary_rfft_gaussian(
     #_test_unitary_rfft_parsevals(x, samp_freq, freq_axis, X)
 
     # remove the phase due to our time shift
-    j = _numpy.complex(0.0,1.0) # sqrt(-1)
+    j = _numpy.complex(0.0,1.0)  # sqrt(-1)
     for i in range(len(freq_axis)):
         f = freq_axis[i]
         inverse_phase_shift = _numpy.exp(j*2.0*_numpy.pi*time_shift*f)
@@ -303,7 +303,7 @@ def power_spectrum(data, freq=1.0):
     # >>> help(numpy.fft.fftpack.rfft) for Numpy's explaination.
     # See Numerical Recipies for a details.
     trans = _numpy.fft.rfft(data[0:nsamps])
-    power = (trans * trans.conj()).real # We want the square of the amplitude.
+    power = (trans * trans.conj()).real  # we want the square of the amplitude
     return (freq_axis, power)
 
 
@@ -350,7 +350,7 @@ def _test_unitary_power_spectrum_sin(sin_freq=10, samp_freq=512, samples=1024):
     imax = _numpy.argmax(power)
 
     expected = _numpy.zeros((len(freq_axis),), dtype=_numpy.float)
-    df = samp_freq/_numpy.float(samples) # df = 1/T, where T = total_time
+    df = samp_freq/_numpy.float(samples)  # df = 1/T, where T = total_time
     i = int(sin_freq/df)
     # average power per unit time is
     #  P = <x(t)**2>
@@ -561,13 +561,13 @@ def avg_power_spectrum(data, freq=1.0, chunk_size=2048,
         raise ValueError(
             'chunk_size {} should be a power of 2'.format(chunk_size))
 
-    nchunks = len(data)/chunk_size # integer division = implicit floor
+    nchunks = len(data)/chunk_size  # integer division = implicit floor
     if overlap:
         chunk_step = chunk_size/2
     else:
         chunk_step = chunk_size
 
-    win = window(chunk_size) # generate a window of the appropriate size
+    win = window(chunk_size)  # generate a window of the appropriate size
     freq_axis = _numpy.linspace(0, freq/2, chunk_size/2+1)
     # nsamps/2+1 b/c zero-freq and nyqist-freq are both fully real.
     # >>> help(numpy.fft.fftpack.rfft) for Numpy's explaination.
@@ -617,9 +617,9 @@ def _test_unitary_avg_power_spectrum_sin(
     imax = _numpy.argmax(power)
 
     expected = _numpy.zeros((len(freq_axis),), dtype=_numpy.float)
-    df = samp_freq/_numpy.float(chunk_size) # df = 1/T, where T = total_time
+    df = samp_freq/_numpy.float(chunk_size)  # df = 1/T, where T = total_time
     i = int(sin_freq/df)
-    expected[i] = 0.5 / df # see _test_unitary_power_spectrum_sin()
+    expected[i] = 0.5 / df  # see _test_unitary_power_spectrum_sin()
 
     print('The power should peak at {} Hz of {} ({}, {})'.format(
         sin_freq, expected[i], freq_axis[imax], power[imax]))