Skip to content
Snippets Groups Projects

Reduction Support

Open Richard Angersbach requested to merge rangersbach/reductions into v2.0-dev
Viewing commit 555a6a83
Show latest version
1 file
+ 5
2
Preferences
Compare changes
@@ -12,7 +12,7 @@ class ReducedAssignment(AssignmentBase):
Symbol for binary operation being applied in the assignment, such as "+",
"*", etc.
"""
binop = None # type: str
binop = None # type: str
@property
def op(self):
@@ -22,6 +22,7 @@ class ReducedAssignment(AssignmentBase):
class AddReducedAssignment(ReducedAssignment):
binop = '+'
class SubReducedAssignment(ReducedAssignment):
binop = '-'
@@ -33,6 +34,7 @@ class MulReducedAssignment(ReducedAssignment):
class MinReducedssignment(ReducedAssignment):
binop = 'min'
class MaxReducedssignment(ReducedAssignment):
binop = 'max'
@@ -45,7 +47,8 @@ reduced_assign_classes = {
]
}
def reduced_assign(lhs, op, rhs):
if op not in reduced_assign_classes:
raise ValueError("Unrecognized operator %s" % op)
return reduced_assign_classes[op](lhs, rhs)
\ No newline at end of file
return reduced_assign_classes[op](lhs, rhs)