mirror of https://github.com/m-labs/artiq.git
language/experiment: attach k_function_info in kernel decorator, do not use star notation for kernel args
This commit is contained in:
parent
903cbfd848
commit
f035507bac
|
@ -1,4 +1,5 @@
|
||||||
import itertools
|
import itertools
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
class Experiment:
|
class Experiment:
|
||||||
channels = ""
|
channels = ""
|
||||||
|
@ -23,16 +24,20 @@ class Experiment:
|
||||||
|
|
||||||
self.kernel_attr_ro = self.parameters
|
self.kernel_attr_ro = self.parameters
|
||||||
|
|
||||||
|
KernelFunctionInfo = namedtuple("KernelFunctionInfo", "core_name k_function")
|
||||||
|
|
||||||
def kernel(arg):
|
def kernel(arg):
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
def real_decorator(k_function):
|
def real_decorator(k_function):
|
||||||
def run_on_core(exp, *k_args, **k_kwargs):
|
def run_on_core(exp, *k_args, **k_kwargs):
|
||||||
getattr(exp, arg).run(k_function, exp, *k_args, **k_kwargs)
|
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 run_on_core
|
||||||
return real_decorator
|
return real_decorator
|
||||||
else:
|
else:
|
||||||
def run_on_core(exp, *k_args, **k_kwargs):
|
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
|
return run_on_core
|
||||||
|
|
||||||
class _DummyTimeManager:
|
class _DummyTimeManager:
|
||||||
|
|
|
@ -4,7 +4,7 @@ from artiq.language import units
|
||||||
from artiq.sim import time
|
from artiq.sim import time
|
||||||
|
|
||||||
class Core:
|
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)
|
return k_function(*k_args, **k_kwargs)
|
||||||
|
|
||||||
class Input:
|
class Input:
|
||||||
|
|
Loading…
Reference in New Issue