From 35d4f75b65ce257c622e475f205731989ef74b85 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 21 Nov 2014 15:55:39 -0800 Subject: [PATCH] transforms: PEP8 --- artiq/transforms/interleave.py | 2 +- artiq/transforms/lower_time.py | 3 ++- artiq/transforms/lower_units.py | 2 +- artiq/transforms/quantize_time.py | 3 ++- artiq/transforms/remove_inter_assigns.py | 1 + artiq/transforms/tools.py | 5 +++-- artiq/transforms/unparse.py | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/artiq/transforms/interleave.py b/artiq/transforms/interleave.py index ab9fbbfee..0a1b794a9 100644 --- a/artiq/transforms/interleave.py +++ b/artiq/transforms/interleave.py @@ -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.finalbody) and all(_get_duration(s) == 0 for s in handler.body - for handler in stmt.handlers)): + for handler in stmt.handlers)): return 0 else: return -1 diff --git a/artiq/transforms/lower_time.py b/artiq/transforms/lower_time.py index d24583b39..aa799de8e 100644 --- a/artiq/transforms/lower_time.py +++ b/artiq/transforms/lower_time.py @@ -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: delay(t) -> now += t diff --git a/artiq/transforms/lower_units.py b/artiq/transforms/lower_units.py index 3428ea11e..917a7a0cf 100644 --- a/artiq/transforms/lower_units.py +++ b/artiq/transforms/lower_units.py @@ -6,7 +6,7 @@ from artiq.language import units def _add_units(f, unit_list): def wrapper(*args): 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 wrapper diff --git a/artiq/transforms/quantize_time.py b/artiq/transforms/quantize_time.py index d545d0984..6f8fe05e8 100644 --- a/artiq/transforms/quantize_time.py +++ b/artiq/transforms/quantize_time.py @@ -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 ref_period. diff --git a/artiq/transforms/remove_inter_assigns.py b/artiq/transforms/remove_inter_assigns.py index 76e8163c9..56d877215 100644 --- a/artiq/transforms/remove_inter_assigns.py +++ b/artiq/transforms/remove_inter_assigns.py @@ -4,6 +4,7 @@ from collections import defaultdict from artiq.transforms.tools import is_ref_transparent, count_all_nodes + class _TargetLister(ast.NodeVisitor): def __init__(self): self.targets = set() diff --git a/artiq/transforms/tools.py b/artiq/transforms/tools.py index 96228ac9a..cfec5396c 100644 --- a/artiq/transforms/tools.py +++ b/artiq/transforms/tools.py @@ -99,12 +99,13 @@ def _is_ref_transparent(dependencies, expr): return _is_ref_transparent(dependencies, expr.operand) elif isinstance(expr, ast.BinOp): 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): return all(_is_ref_transparent(dependencies, v) for v in expr.values) elif isinstance(expr, ast.Call): 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: return False diff --git a/artiq/transforms/unparse.py b/artiq/transforms/unparse.py index 6917dc983..cacd6e73b 100644 --- a/artiq/transforms/unparse.py +++ b/artiq/transforms/unparse.py @@ -385,7 +385,8 @@ class _Unparser: self.dispatch(k) self.write(": ") 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("}") def _Tuple(self, t):