forked from M-Labs/artiq
1
0
Fork 0

Merge branch 'namespace_all'

* namespace_all:
  use __all__ to structure the namespace
This commit is contained in:
Robert Jördens 2015-07-04 18:38:26 -06:00
commit 380f498284
6 changed files with 37 additions and 14 deletions

View File

@ -1,2 +1,5 @@
from artiq import language
from artiq.language import *
__all__ = []
__all__.extend(language.__all__)

View File

@ -1,4 +1,11 @@
from artiq.language import core, experiment, db, units
from artiq.language.core import *
from artiq.language.experiment import Experiment
from artiq.language.experiment import *
from artiq.language.db import *
from artiq.language.units import *
__all__ = []
__all__.extend(core.__all__)
__all__.extend(experiment.__all__)
__all__.extend(db.__all__)
__all__.extend(units.__all__)

View File

@ -2,8 +2,20 @@
Core ARTIQ extensions to the Python language.
"""
from collections import namedtuple as _namedtuple
from functools import wraps as _wraps
from collections import namedtuple
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):
@ -65,7 +77,7 @@ def round64(x):
return int64(round(x))
_KernelFunctionInfo = _namedtuple("_KernelFunctionInfo", "core_name k_function")
_KernelFunctionInfo = namedtuple("_KernelFunctionInfo", "core_name k_function")
def kernel(arg):
@ -89,16 +101,16 @@ def kernel(arg):
"""
if isinstance(arg, str):
def real_decorator(k_function):
@_wraps(k_function)
@wraps(k_function)
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)
run_on_core.k_function_info = _KernelFunctionInfo(
core_name=arg, k_function=k_function)
return run_on_core
return real_decorator
else:
@_wraps(arg)
@wraps(arg)
def run_on_core(exp, *k_args, **k_kwargs):
return exp.core.run(arg, ((exp,) + k_args), k_kwargs)
run_on_core.k_function_info = _KernelFunctionInfo(
@ -160,13 +172,6 @@ def set_syscall_manager(syscall_manager):
global _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:
"""In a sequential block, statements are executed one after another, with

View File

@ -2,6 +2,9 @@
Connection to device, parameter and result database.
"""
__all__ = ["Device", "NoDefault", "Parameter", "Argument", "Result", "AutoDB"]
class _AttributeKind:
pass

View File

@ -1,5 +1,7 @@
from inspect import isclass
__all__ = ["Experiment", "has_analyze", "is_experiment"]
class Experiment:
"""Base class for experiments.

View File

@ -1,3 +1,5 @@
__all__ = []
_prefixes_str = "pnum_kMG"
_smallest_prefix_exp = -12
@ -8,6 +10,7 @@ def _register_unit(unit, prefixes):
if prefix in prefixes:
full_name = prefix + unit if prefix != "_" else unit
globals()[full_name] = 10.**exponent
__all__.append(full_name)
exponent += 3