def test_random_case(self): n = random.randint(1,20) made = u.make_specs(n) self.assertEqual(n, len(made)) for spec in made: self.assertTrue(isinstance(spec, tuple)) self.assertEqual(len(spec), 4)
def main(): specs = [u.make_specs(1) for i in range(N_SIGNALS)] makers = [s.Periodic(spec, noise=0.0) for spec in specs] # take data to be a list of tuples [... (nsr, error) ...] fft_data = [] lpsvd_data = [] noises = linspace(0.0, 1.0, N_NOISES) for nsr in noises: for spec,maker in zip(specs,makers): maker.noise = 0.0 amp = 2.0 * ( average([m**2 for m in maker.time_series(D_LENGTH)]) ) maker.noise = nsr seed = maker.time_series(D_LENGTH) fft_d = fft.fft(seed) fft_r = [c.real for c in fft.ifft(fft_d)] lpsvd_d = l.LPSVD(seed, count=2.0).decomposition() lpsvd_r = lpsvd_d.time_series(D_LENGTH) maker.noise = 0.0 clean = maker.time_series(D_LENGTH) fft_err = 1.0 * (u.mean_sq_error(clean,fft_r)) / amp lpsvd_err = 1.0 * (u.mean_sq_error(clean,lpsvd_r)) / amp fft_data.append((nsr, fft_err)) lpsvd_data.append((nsr, lpsvd_err)) for fd in fft_data: print str(fd[0])+"\t"+str(fd[1]) for ld in lpsvd_data: print str(ld[0])+"\t"+str(ld[1]) do_plot(fft_data, lpsvd_data) return None
def test_zeroth_case(self): made = u.make_specs(0) self.assertEqual([], made)