From 75dfa95b4d0f9124631fd98b89540827f008d4d3 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Sun, 5 Apr 2015 04:24:44 -0600 Subject: [PATCH] wavesynth: move test code to unittests, fix mutability style --- artiq/test/wavesynth.py | 6 ++++++ artiq/wavesynth/compute_samples.py | 21 ++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/artiq/test/wavesynth.py b/artiq/test/wavesynth.py index 7d6b82f00..8a40cd71b 100644 --- a/artiq/test/wavesynth.py +++ b/artiq/test/wavesynth.py @@ -116,3 +116,9 @@ class TestSynthesizer(unittest.TestCase): def test_run(self): x, y = self.drive() + + @unittest.skip("manual/visual test") + def test_plot(self): + import cairoplot + x, y = self.drive() + cairoplot.scatter_plot("plot.png", [x, y]) diff --git a/artiq/wavesynth/compute_samples.py b/artiq/wavesynth/compute_samples.py index ed81f44b3..31a345480 100644 --- a/artiq/wavesynth/compute_samples.py +++ b/artiq/wavesynth/compute_samples.py @@ -8,7 +8,6 @@ def discrete_compensate(c): if len(c) > 3: c[1] += c[3]/6 c[2] += c[3] - return c class Spline: @@ -16,7 +15,8 @@ class Spline: self.c = [0.0] def set_coefficients(self, c): - self.c = discrete_compensate(copy(c)) + self.c = copy(c) + discrete_compensate(self.c) def next(self): r = self.c[0] @@ -32,7 +32,8 @@ class SplinePhase: def set_coefficients(self, c): self.c0 = c[0] - self.c[1:] = discrete_compensate(c[1:]) + self.c[1:] = c[1:] + discrete_compensate(self.c[1:]) def clear(self): self.c[0] = 0.0 @@ -128,17 +129,3 @@ class Synthesizer: except StopIteration: self.line_iter = None return r - - -def main(): - from artiq.test.wavesynth import TestSynthesizer - import cairoplot - - t = TestSynthesizer() - t.setUp() - x, y = t.drive() - cairoplot.scatter_plot("plot.png", [x, y]) - - -if __name__ == "__main__": - main()