Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0abea0c

Browse files
committedJun 29, 2015
use __all__ to structure the namespace
1 parent d1c4cf0 commit 0abea0c

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed
 

Diff for: ‎artiq/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
from artiq import language
22
from artiq.language import *
3+
4+
__all__ = []
5+
__all__.extend(language.__all__)

Diff for: ‎artiq/language/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
from artiq.language import core, experiment, db, units
12
from artiq.language.core import *
2-
from artiq.language.experiment import Experiment
3+
from artiq.language.experiment import *
34
from artiq.language.db import *
45
from artiq.language.units import *
6+
7+
__all__ = []
8+
__all__.extend(core.__all__)
9+
__all__.extend(experiment.__all__)
10+
__all__.extend(db.__all__)
11+
__all__.extend(units.__all__)

Diff for: ‎artiq/language/core.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22
Core ARTIQ extensions to the Python language.
33
"""
44

5-
from collections import namedtuple as _namedtuple
6-
from functools import wraps as _wraps
5+
from collections import namedtuple
6+
from functools import wraps
7+
8+
9+
__all__ = ["int64", "round64", "kernel", "portable",
10+
"set_time_manager", "set_syscall_manager", "set_watchdog_factory",
11+
"RuntimeException"]
12+
13+
# global namespace for kernels
14+
kernel_globals = ("sequential", "parallel",
15+
"delay", "now", "at", "time_to_cycles", "cycles_to_time",
16+
"syscall", "watchdog")
17+
__all__.extend(kernel_globals)
718

819

920
class int64(int):
@@ -67,7 +78,7 @@ def round64(x):
6778
return int64(round(x))
6879

6980

70-
_KernelFunctionInfo = _namedtuple("_KernelFunctionInfo", "core_name k_function")
81+
_KernelFunctionInfo = namedtuple("_KernelFunctionInfo", "core_name k_function")
7182

7283

7384
def kernel(arg):
@@ -92,16 +103,16 @@ def kernel(arg):
92103
"""
93104
if isinstance(arg, str):
94105
def real_decorator(k_function):
95-
@_wraps(k_function)
106+
@wraps(k_function)
96107
def run_on_core(exp, *k_args, **k_kwargs):
97-
return getattr(exp, arg).run(k_function,
108+
return getattr(exp, arg).run(k_function,
98109
((exp,) + k_args), k_kwargs)
99110
run_on_core.k_function_info = _KernelFunctionInfo(
100111
core_name=arg, k_function=k_function)
101112
return run_on_core
102113
return real_decorator
103114
else:
104-
@_wraps(arg)
115+
@wraps(arg)
105116
def run_on_core(exp, *k_args, **k_kwargs):
106117
return exp.core.run(arg, ((exp,) + k_args), k_kwargs)
107118
run_on_core.k_function_info = _KernelFunctionInfo(
@@ -165,12 +176,6 @@ def set_syscall_manager(syscall_manager):
165176
global _syscall_manager
166177
_syscall_manager = syscall_manager
167178

168-
# global namespace for kernels
169-
170-
kernel_globals = ("sequential", "parallel",
171-
"delay", "now", "at", "time_to_cycles", "cycles_to_time",
172-
"syscall", "watchdog")
173-
174179

175180
class _Sequential:
176181
"""In a sequential block, statements are executed one after another, with

Diff for: ‎artiq/language/db.py

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Connection to device, parameter and result database.
33
"""
44

5+
__all__ = ["Device", "NoDefault", "Parameter", "Argument", "Result", "AutoDB"]
6+
7+
58
class _AttributeKind:
69
pass
710

Diff for: ‎artiq/language/experiment.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from inspect import isclass
22

3+
__all__ = ["Experiment", "has_analyze", "is_experiment"]
4+
35

46
class Experiment:
57
"""Base class for experiments.

Diff for: ‎artiq/language/units.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = []
2+
13
_prefixes_str = "pnum_kMG"
24
_smallest_prefix_exp = -12
35

@@ -8,6 +10,7 @@ def _register_unit(unit, prefixes):
810
if prefix in prefixes:
911
full_name = prefix + unit if prefix != "_" else unit
1012
globals()[full_name] = 10.**exponent
13+
__all__.append(full_name)
1114
exponent += 3
1215

1316

0 commit comments

Comments
 (0)
Please sign in to comment.