From: Luke Kenneth Casson Leighton Date: Thu, 1 Jun 2023 17:49:11 +0000 (+0100) Subject: whitespace cleanup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=66e826e287f977e597b2a5795ca1c37145a4c633;p=openpower-isa.git whitespace cleanup --- diff --git a/src/openpower/test_visitor.py b/src/openpower/test_visitor.py index 3bc11c7d..dc172935 100644 --- a/src/openpower/test_visitor.py +++ b/src/openpower/test_visitor.py @@ -77,7 +77,7 @@ class ConcreteModel: def is_expression_type(self): return False -class Var: +class Var: def __init__(self, name): self.name = name def is_expression_type(self): @@ -85,7 +85,7 @@ class Var: def __repr__(self): return self.name -class Set(BaseExpression): +class Set(BaseExpression): def __init__(self, initialize=None): super().__init__("set", initialize) def is_expression_type(self): @@ -124,7 +124,8 @@ class BaseStreamBasedVisitorTests(object): def test_beforeChild(self): def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, [child] walker = StreamBasedExpressionVisitor(beforeChild=before) @@ -143,7 +144,8 @@ class BaseStreamBasedVisitorTests(object): def test_initializeWalker_beforeChild(self): def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, child def initialize(expr): @@ -171,7 +173,8 @@ class BaseStreamBasedVisitorTests(object): def test_beforeChild_exitNode(self): def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, [child] def exit(node, data): @@ -181,7 +184,8 @@ class BaseStreamBasedVisitorTests(object): data.insert(0, str(node)) return data - walker = StreamBasedExpressionVisitor(beforeChild=before, exitNode=exit) + walker = StreamBasedExpressionVisitor(beforeChild=before, + exitNode=exit) ans = self.walk(walker, self.e) m = self.m ref = [ @@ -204,7 +208,8 @@ class BaseStreamBasedVisitorTests(object): i = [0] def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, [child] def enter(node): @@ -242,7 +247,8 @@ class BaseStreamBasedVisitorTests(object): def test_old_beforeChild(self): def before(node, child): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, [child] os = StringIO() @@ -276,7 +282,8 @@ class BaseStreamBasedVisitorTests(object): def accept(node, data, child_result, child_idx): return data + child_result - walker = StreamBasedExpressionVisitor(enterNode=enter, acceptChildResult=accept) + walker = StreamBasedExpressionVisitor(enterNode=enter, + acceptChildResult=accept) # 4 operators, 6 leaf nodes self.assertEqual(self.walk(walker, self.e), 10) @@ -286,7 +293,8 @@ class BaseStreamBasedVisitorTests(object): def test_enterNode(self): # This is an alternative way to implement the beforeChild test: def enter(node): - if type(node) in nonpyomo_leaf_types or not node.is_expression_type(): + if type(node) in nonpyomo_leaf_types or \ + not node.is_expression_type(): return (), [node] return node.args, [] @@ -308,7 +316,8 @@ class BaseStreamBasedVisitorTests(object): def test_enterNode_noLeafList(self): # This is an alternative way to implement the beforeChild test: def enter(node): - if type(node) in nonpyomo_leaf_types or not node.is_expression_type(): + if type(node) in nonpyomo_leaf_types or \ + not node.is_expression_type(): return (), node return node.args, [] @@ -330,7 +339,8 @@ class BaseStreamBasedVisitorTests(object): def test_enterNode_withFinalize(self): # This is an alternative way to implement the beforeChild test: def enter(node): - if type(node) in nonpyomo_leaf_types or not node.is_expression_type(): + if type(node) in nonpyomo_leaf_types or \ + not node.is_expression_type(): return (), node return node.args, [] @@ -340,7 +350,8 @@ class BaseStreamBasedVisitorTests(object): else: return [result] - walker = StreamBasedExpressionVisitor(enterNode=enter, finalizeResult=finalize) + walker = StreamBasedExpressionVisitor(enterNode=enter, + finalizeResult=finalize) m = self.m ans = self.walk(walker, self.e) @@ -383,7 +394,8 @@ class BaseStreamBasedVisitorTests(object): def before(node, child, child_idx): counts[0] += 1 - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, None def accept(node, data, child_result, child_idx): @@ -405,7 +417,8 @@ class BaseStreamBasedVisitorTests(object): def before(node, child): counts[0] += 1 - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, None def accept(node, data, child_result): @@ -447,7 +460,8 @@ class BaseStreamBasedVisitorTests(object): ans = [] def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, child def accept(node, data, child_result, child_idx): @@ -470,7 +484,8 @@ class BaseStreamBasedVisitorTests(object): ans = [] def before(node, child, child_idx): - if type(child) in nonpyomo_leaf_types or not child.is_expression_type(): + if type(child) in nonpyomo_leaf_types or \ + not child.is_expression_type(): return False, child def accept(node, data, child_result, child_idx): @@ -610,13 +625,15 @@ Finalize""", self.ans.append("Exit %s" % (name(node))) def beforeChild(self, node, child, child_idx): - self.ans.append("Before %s (from %s)" % (name(child), name(node))) + self.ans.append("Before %s (from %s)" % (name(child), + name(node))) def acceptChildResult(self, node, data, child_result, child_idx): self.ans.append("Accept into %s" % (name(node))) def afterChild(self, node, child, child_idx): - self.ans.append("After %s (from %s)" % (name(child), name(node))) + self.ans.append("After %s (from %s)" % (name(child), + name(node))) def finalizeResult(self, result): self.ans.append("Finalize") @@ -695,13 +712,15 @@ Finalize""", self.ans.append("Exit %s" % (name(node))) def beforeChild(self, node, child): - self.ans.append("Before %s (from %s)" % (name(child), name(node))) + self.ans.append("Before %s (from %s)" % (name(child), + name(node))) def acceptChildResult(self, node, data, child_result): self.ans.append("Accept into %s" % (name(node))) def afterChild(self, node, child): - self.ans.append("After %s (from %s)" % (name(child), name(node))) + self.ans.append("After %s (from %s)" % (name(child), + name(node))) def finalizeResult(self, result): self.ans.append("Finalize") @@ -860,7 +879,8 @@ class TestStreamBasedExpressionVisitor_Deep(unittest.TestCase): return data + 1 return StreamBasedExpressionVisitor( - beforeChild=before, acceptChildResult=accept, enterNode=enter, exitNode=exit + beforeChild=before, acceptChildResult=accept, + enterNode=enter, exitNode=exit ) def run_walker(self, walker): @@ -893,7 +913,8 @@ class TestStreamBasedExpressionVisitor_Deep(unittest.TestCase): # We have not yet determined how to trigger the # RecursionError on PyPy cases = [(0, "")] - elif os.environ.get('GITHUB_ACTIONS', '') and sys.platform.startswith('win'): + elif os.environ.get('GITHUB_ACTIONS', '') and \ + sys.platform.startswith('win'): # The test for handling RecursionError appears to fail # inexplicably on GHA/Windows under pytest: the # RecursionError that is supposed to be raised is not