# X[k] = SUM x[m] exp (-j 2pi km /n)
# m=0
# (see http://www.tramy.us/numpybook.pdf)
- j = _numpy.complex(0,1)
+ j = _numpy.complex(0, 1)
n = len(xs)
Xa = []
for k in range(n):
Xa.append(sum([x * _numpy.exp(-j * 2 * _numpy.pi * k * m / n)
- for x,m in zip(xs,range(n))]))
+ for x,m in zip(xs, range(n))]))
if k < len(Xs):
if (Xs[k] - Xa[k]) / _numpy.abs(Xa[k]) >= 1e-6:
raise ValueError(
def _test_rfft_suite():
print('Test numpy rfft definition')
- xs = [1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1]
+ xs = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]
_test_rfft(xs, _numpy.fft.rfft(xs))
def _test_unitary_rfft_parsevals_suite():
print("Test unitary rfft on Parseval's theorem")
- xs = [1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1]
+ xs = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]
dt = _numpy.pi
freqs,Xs = unitary_rfft(xs, 1.0 / dt)
_test_unitary_rfft_parsevals(xs, 1.0 / dt, freqs, Xs)
#_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)
#_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)
def _test_unitary_power_spectrum_gaussian(
- area=2.5, mean=5, std=1, samp_freq=10.24 ,samples=512):
+ area=2.5, mean=5, std=1, samp_freq=10.24, samples=512):
x = _numpy.zeros((samples,), dtype=_numpy.float)
mean = _numpy.float(mean)
for i in range(samples):