mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
Merge branch 'namespace_all'
* namespace_all: use __all__ to structure the namespace
This commit is contained in:
commit
380f498284
@ -1,2 +1,5 @@
|
|||||||
from artiq import language
|
from artiq import language
|
||||||
from artiq.language import *
|
from artiq.language import *
|
||||||
|
|
||||||
|
__all__ = []
|
||||||
|
__all__.extend(language.__all__)
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
|
from artiq.language import core, experiment, db, units
|
||||||
from artiq.language.core import *
|
from artiq.language.core import *
|
||||||
from artiq.language.experiment import Experiment
|
from artiq.language.experiment import *
|
||||||
from artiq.language.db import *
|
from artiq.language.db import *
|
||||||
from artiq.language.units import *
|
from artiq.language.units import *
|
||||||
|
|
||||||
|
__all__ = []
|
||||||
|
__all__.extend(core.__all__)
|
||||||
|
__all__.extend(experiment.__all__)
|
||||||
|
__all__.extend(db.__all__)
|
||||||
|
__all__.extend(units.__all__)
|
||||||
|
@ -2,8 +2,20 @@
|
|||||||
Core ARTIQ extensions to the Python language.
|
Core ARTIQ extensions to the Python language.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections import namedtuple as _namedtuple
|
from collections import namedtuple
|
||||||
from functools import wraps as _wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["int64", "round64", "kernel", "portable",
|
||||||
|
"set_time_manager", "set_syscall_manager", "set_watchdog_factory",
|
||||||
|
"RuntimeException"]
|
||||||
|
|
||||||
|
# global namespace for kernels
|
||||||
|
kernel_globals = ("sequential", "parallel",
|
||||||
|
"delay_mu", "now_mu", "at_mu", "delay",
|
||||||
|
"seconds_to_mu", "mu_to_seconds",
|
||||||
|
"syscall", "watchdog")
|
||||||
|
__all__.extend(kernel_globals)
|
||||||
|
|
||||||
|
|
||||||
class int64(int):
|
class int64(int):
|
||||||
@ -65,7 +77,7 @@ def round64(x):
|
|||||||
return int64(round(x))
|
return int64(round(x))
|
||||||
|
|
||||||
|
|
||||||
_KernelFunctionInfo = _namedtuple("_KernelFunctionInfo", "core_name k_function")
|
_KernelFunctionInfo = namedtuple("_KernelFunctionInfo", "core_name k_function")
|
||||||
|
|
||||||
|
|
||||||
def kernel(arg):
|
def kernel(arg):
|
||||||
@ -89,7 +101,7 @@ def kernel(arg):
|
|||||||
"""
|
"""
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
def real_decorator(k_function):
|
def real_decorator(k_function):
|
||||||
@_wraps(k_function)
|
@wraps(k_function)
|
||||||
def run_on_core(exp, *k_args, **k_kwargs):
|
def run_on_core(exp, *k_args, **k_kwargs):
|
||||||
return getattr(exp, arg).run(k_function,
|
return getattr(exp, arg).run(k_function,
|
||||||
((exp,) + k_args), k_kwargs)
|
((exp,) + k_args), k_kwargs)
|
||||||
@ -98,7 +110,7 @@ def kernel(arg):
|
|||||||
return run_on_core
|
return run_on_core
|
||||||
return real_decorator
|
return real_decorator
|
||||||
else:
|
else:
|
||||||
@_wraps(arg)
|
@wraps(arg)
|
||||||
def run_on_core(exp, *k_args, **k_kwargs):
|
def run_on_core(exp, *k_args, **k_kwargs):
|
||||||
return exp.core.run(arg, ((exp,) + k_args), k_kwargs)
|
return exp.core.run(arg, ((exp,) + k_args), k_kwargs)
|
||||||
run_on_core.k_function_info = _KernelFunctionInfo(
|
run_on_core.k_function_info = _KernelFunctionInfo(
|
||||||
@ -160,13 +172,6 @@ def set_syscall_manager(syscall_manager):
|
|||||||
global _syscall_manager
|
global _syscall_manager
|
||||||
_syscall_manager = syscall_manager
|
_syscall_manager = syscall_manager
|
||||||
|
|
||||||
# global namespace for kernels
|
|
||||||
|
|
||||||
kernel_globals = ("sequential", "parallel",
|
|
||||||
"delay_mu", "now_mu", "at_mu", "delay",
|
|
||||||
"seconds_to_mu", "mu_to_seconds",
|
|
||||||
"syscall", "watchdog")
|
|
||||||
|
|
||||||
|
|
||||||
class _Sequential:
|
class _Sequential:
|
||||||
"""In a sequential block, statements are executed one after another, with
|
"""In a sequential block, statements are executed one after another, with
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
Connection to device, parameter and result database.
|
Connection to device, parameter and result database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["Device", "NoDefault", "Parameter", "Argument", "Result", "AutoDB"]
|
||||||
|
|
||||||
|
|
||||||
class _AttributeKind:
|
class _AttributeKind:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
from inspect import isclass
|
from inspect import isclass
|
||||||
|
|
||||||
|
__all__ = ["Experiment", "has_analyze", "is_experiment"]
|
||||||
|
|
||||||
|
|
||||||
class Experiment:
|
class Experiment:
|
||||||
"""Base class for experiments.
|
"""Base class for experiments.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
__all__ = []
|
||||||
|
|
||||||
_prefixes_str = "pnum_kMG"
|
_prefixes_str = "pnum_kMG"
|
||||||
_smallest_prefix_exp = -12
|
_smallest_prefix_exp = -12
|
||||||
|
|
||||||
@ -8,6 +10,7 @@ def _register_unit(unit, prefixes):
|
|||||||
if prefix in prefixes:
|
if prefix in prefixes:
|
||||||
full_name = prefix + unit if prefix != "_" else unit
|
full_name = prefix + unit if prefix != "_" else unit
|
||||||
globals()[full_name] = 10.**exponent
|
globals()[full_name] = 10.**exponent
|
||||||
|
__all__.append(full_name)
|
||||||
exponent += 3
|
exponent += 3
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user