From 2f58cf6aff205f0687b15d71c83b6e98a2b29985 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 5 Oct 2014 16:24:21 +0800 Subject: [PATCH] examples: add main function --- examples/al_spectroscopy.py | 5 ++++- examples/compiler_test.py | 5 ++++- examples/dds_test.py | 5 ++++- examples/mandelbrot.py | 5 ++++- examples/photon_histogram.py | 5 ++++- examples/simple_simulation.py | 5 ++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/al_spectroscopy.py b/examples/al_spectroscopy.py index e0ed120b7..1a94150e9 100644 --- a/examples/al_spectroscopy.py +++ b/examples/al_spectroscopy.py @@ -32,7 +32,7 @@ class AluminumSpectroscopy(AutoContext): return state_0_count -if __name__ == "__main__": +def main(): from artiq.sim import devices as sd from artiq.sim import time @@ -51,3 +51,6 @@ if __name__ == "__main__": ) exp.run() print(time.manager.format_timeline()) + +if __name__ == "__main__": + main() diff --git a/examples/compiler_test.py b/examples/compiler_test.py index c9258fa63..b16be5fe1 100644 --- a/examples/compiler_test.py +++ b/examples/compiler_test.py @@ -29,7 +29,7 @@ class CompilerTest(AutoContext): self.print_done() -if __name__ == "__main__": +def main(): from artiq.devices import corecom_dummy, core, dds_core coredev = core.Core(corecom_dummy.CoreCom()) @@ -45,3 +45,6 @@ if __name__ == "__main__": reg_channel=3, rtio_channel=3) ) exp.run(3, 100*us) + +if __name__ == "__main__": + main() diff --git a/examples/dds_test.py b/examples/dds_test.py index fd9427480..0137ff092 100644 --- a/examples/dds_test.py +++ b/examples/dds_test.py @@ -22,7 +22,7 @@ class DDSTest(AutoContext): self.led.set(0) -if __name__ == "__main__": +def main(): with corecom_serial.CoreCom() as com: coredev = core.Core(com) exp = DDSTest( @@ -38,3 +38,6 @@ if __name__ == "__main__": led=gpio_core.GPIOOut(core=coredev, channel=1) ) exp.run() + +if __name__ == "__main__": + main() diff --git a/examples/mandelbrot.py b/examples/mandelbrot.py index be2e2b0bb..6a602ae86 100644 --- a/examples/mandelbrot.py +++ b/examples/mandelbrot.py @@ -38,7 +38,10 @@ class Mandelbrot(AutoContext): self.row() -if __name__ == "__main__": +def main(): with corecom_serial.CoreCom() as com: exp = Mandelbrot(core=core.Core(com)) exp.run() + +if __name__ == "__main__": + main() diff --git a/examples/photon_histogram.py b/examples/photon_histogram.py index cb81841b1..27856dae4 100644 --- a/examples/photon_histogram.py +++ b/examples/photon_histogram.py @@ -35,7 +35,7 @@ class PhotonHistogram(AutoContext): self.report(i, hist[i]) -if __name__ == "__main__": +def main(): with corecom_serial.CoreCom() as com: coredev = core.Core(com) exp = PhotonHistogram( @@ -49,3 +49,6 @@ if __name__ == "__main__": nbins=100 ) exp.run() + +if __name__ == "__main__": + main() diff --git a/examples/simple_simulation.py b/examples/simple_simulation.py index 1992b7459..3f28e9363 100644 --- a/examples/simple_simulation.py +++ b/examples/simple_simulation.py @@ -15,7 +15,7 @@ class SimpleSimulation(AutoContext): self.d.pulse(400*MHz, 20*us) -if __name__ == "__main__": +def main(): from artiq.sim import devices as sd from artiq.sim import time @@ -28,3 +28,6 @@ if __name__ == "__main__": ) exp.run() print(time.manager.format_timeline()) + +if __name__ == "__main__": + main()