2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 11:18:27 +08:00

language/experiment: attach k_function_info in kernel decorator, do not use star notation for kernel args

This commit is contained in:
Sebastien Bourdeauducq 2014-06-16 21:51:58 +02:00
parent 903cbfd848
commit f035507bac
2 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import itertools
from collections import namedtuple
class Experiment:
channels = ""
@ -23,16 +24,20 @@ class Experiment:
self.kernel_attr_ro = self.parameters
KernelFunctionInfo = namedtuple("KernelFunctionInfo", "core_name k_function")
def kernel(arg):
if isinstance(arg, str):
def real_decorator(k_function):
def run_on_core(exp, *k_args, **k_kwargs):
getattr(exp, arg).run(k_function, exp, *k_args, **k_kwargs)
return run_on_core
getattr(exp, arg).run(k_function, ((exp,) + k_args), k_kwargs)
run_on_core.k_function_info = KernelFunctionInfo(core_name=arg, k_function=k_function)
return run_on_core
return real_decorator
else:
def run_on_core(exp, *k_args, **k_kwargs):
exp.core.run(arg, exp, *k_args, **k_kwargs)
exp.core.run(arg, ((exp,) + k_args), k_kwargs)
run_on_core.k_function_info = KernelFunctionInfo(core_name="core", k_function=arg)
return run_on_core
class _DummyTimeManager:

View File

@ -4,7 +4,7 @@ from artiq.language import units
from artiq.sim import time
class Core:
def run(self, k_function, *k_args, **k_kwargs):
def run(self, k_function, k_args, k_kwargs):
return k_function(*k_args, **k_kwargs)
class Input: