forked from M-Labs/artiq
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
|
||||
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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user