transforms: PEP8

This commit is contained in:
Sebastien Bourdeauducq 2014-11-21 15:55:39 -08:00
parent 65567e1201
commit 35d4f75b65
7 changed files with 12 additions and 7 deletions

View File

@ -22,7 +22,7 @@ def _get_duration(stmt):
and all(_get_duration(s) == 0 for s in stmt.orelse) and all(_get_duration(s) == 0 for s in stmt.orelse)
and all(_get_duration(s) == 0 for s in stmt.finalbody) and all(_get_duration(s) == 0 for s in stmt.finalbody)
and all(_get_duration(s) == 0 for s in handler.body and all(_get_duration(s) == 0 for s in handler.body
for handler in stmt.handlers)): for handler in stmt.handlers)):
return 0 return 0
else: else:
return -1 return -1

View File

@ -1,4 +1,5 @@
"""This transform implements time management functions (delay/now/at) """
This transform implements time management functions (delay/now/at)
using an accumulator 'now' and simple replacement rules: using an accumulator 'now' and simple replacement rules:
delay(t) -> now += t delay(t) -> now += t

View File

@ -6,7 +6,7 @@ from artiq.language import units
def _add_units(f, unit_list): def _add_units(f, unit_list):
def wrapper(*args): def wrapper(*args):
new_args = [arg if unit is None else units.Quantity(arg, unit) new_args = [arg if unit is None else units.Quantity(arg, unit)
for arg, unit in zip(args, unit_list)] for arg, unit in zip(args, unit_list)]
return f(*new_args) return f(*new_args)
return wrapper return wrapper

View File

@ -1,4 +1,5 @@
"""This transform turns calls to delay/now/at that use non-integer time """
This transform turns calls to delay/now/at that use non-integer time
expressed in seconds into calls that use int64 time expressed in multiples of expressed in seconds into calls that use int64 time expressed in multiples of
ref_period. ref_period.

View File

@ -4,6 +4,7 @@ from collections import defaultdict
from artiq.transforms.tools import is_ref_transparent, count_all_nodes from artiq.transforms.tools import is_ref_transparent, count_all_nodes
class _TargetLister(ast.NodeVisitor): class _TargetLister(ast.NodeVisitor):
def __init__(self): def __init__(self):
self.targets = set() self.targets = set()

View File

@ -99,12 +99,13 @@ def _is_ref_transparent(dependencies, expr):
return _is_ref_transparent(dependencies, expr.operand) return _is_ref_transparent(dependencies, expr.operand)
elif isinstance(expr, ast.BinOp): elif isinstance(expr, ast.BinOp):
return (_is_ref_transparent(dependencies, expr.left) return (_is_ref_transparent(dependencies, expr.left)
and _is_ref_transparent(dependencies, expr.right)) and _is_ref_transparent(dependencies, expr.right))
elif isinstance(expr, ast.BoolOp): elif isinstance(expr, ast.BoolOp):
return all(_is_ref_transparent(dependencies, v) for v in expr.values) return all(_is_ref_transparent(dependencies, v) for v in expr.values)
elif isinstance(expr, ast.Call): elif isinstance(expr, ast.Call):
return (expr.func.id in _replaceable_funcs and return (expr.func.id in _replaceable_funcs and
all(_is_ref_transparent(dependencies, arg) for arg in expr.args)) all(_is_ref_transparent(dependencies, arg)
for arg in expr.args))
else: else:
return False return False

View File

@ -385,7 +385,8 @@ class _Unparser:
self.dispatch(k) self.dispatch(k)
self.write(": ") self.write(": ")
self.dispatch(v) self.dispatch(v)
_interleave(lambda: self.write(", "), write_pair, zip(t.keys, t.values)) _interleave(lambda: self.write(", "), write_pair,
zip(t.keys, t.values))
self.write("}") self.write("}")
def _Tuple(self, t): def _Tuple(self, t):