コード例 #1
0
    def test_can_specify_frequency(self):
        gen = CosineWaveGenerator(1, 2)

        self.assertAlmostEquals(gen.generate(0.0), 1)
        self.assertAlmostEquals(gen.generate(0.125), 0)
        self.assertAlmostEquals(gen.generate(0.25), -1)
        self.assertAlmostEquals(gen.generate(0.375), 0)
        self.assertAlmostEquals(gen.generate(0.5), 1)
        self.assertAlmostEquals(gen.generate(0.625), 0)
        self.assertAlmostEquals(gen.generate(0.75), -1)
        self.assertAlmostEquals(gen.generate(0.875), 0)
        self.assertAlmostEquals(gen.generate(1.0), 1)
コード例 #2
0
    def test_can_specify_amplitude(self):
        gen = CosineWaveGenerator(2, 1)

        self.assertAlmostEquals(gen.generate(0.0), 2)
        self.assertAlmostEquals(gen.generate(0.25), 0)
        self.assertAlmostEquals(gen.generate(0.5), -2)
        self.assertAlmostEquals(gen.generate(0.75), 0)
        self.assertAlmostEquals(gen.generate(1.0), 2)
コード例 #3
0
    def test_can_specify_amplitude(self):
        gen = CosineWaveGenerator(2, 1)

        self.assertAlmostEquals(gen.generate(0.0), 2)
        self.assertAlmostEquals(gen.generate(0.25), 0)
        self.assertAlmostEquals(gen.generate(0.5), -2)
        self.assertAlmostEquals(gen.generate(0.75), 0)
        self.assertAlmostEquals(gen.generate(1.0), 2)
コード例 #4
0
    def test_can_specify_frequency(self):
        gen = CosineWaveGenerator(1, 2)

        self.assertAlmostEquals(gen.generate(0.0), 1)
        self.assertAlmostEquals(gen.generate(0.125), 0)
        self.assertAlmostEquals(gen.generate(0.25), -1)
        self.assertAlmostEquals(gen.generate(0.375), 0)
        self.assertAlmostEquals(gen.generate(0.5), 1)
        self.assertAlmostEquals(gen.generate(0.625), 0)
        self.assertAlmostEquals(gen.generate(0.75), -1)
        self.assertAlmostEquals(gen.generate(0.875), 0)
        self.assertAlmostEquals(gen.generate(1.0), 1)