예제 #1
0
func TestPwelch(t *testing.T) {

	for _, v := range pwelchTests {
		p, freqs := Pwelch(v.x, v.fs, v.opts)
		if !dsputils.PrettyClose(p, v.p) {
			t.Error("Pwelch Pxx error\n   input:", v.x, "\n  output:", p, "\nexpected:", v.p)
		}

		if !dsputils.PrettyClose(freqs, v.freqs) {
			t.Error("Pwelch freqs error\n   input:", v.x, "\n  output:", freqs, "\nexpected:", v.freqs)
		}
	}
}
예제 #2
0
func TestWindowFunctions(t *testing.T) {
	for _, v := range windowTests {
		o := Hamming(v.in)
		if !dsputils.PrettyClose(o, v.hamming) {
			t.Error("hamming error\ninput:", v.in, "\noutput:", o, "\nexpected:", v.hamming)
		}

		o = Hann(v.in)
		if !dsputils.PrettyClose(o, v.hann) {
			t.Error("hann error\ninput:", v.in, "\noutput:", o, "\nexpected:", v.hann)
		}

		o = Bartlett(v.in)
		if !dsputils.PrettyClose(o, v.bartlett) {
			t.Error("bartlett error\ninput:", v.in, "\noutput:", o, "\nexpected:", v.bartlett)
		}

		o = Rectangular(v.in)
		Apply(o, Hamming)
		if !dsputils.PrettyClose(o, v.hamming) {
			t.Error("apply error\noutput:", o, "\nexpected:", v.hamming)
		}
	}
}