def reflected_binary_operator(op):
 assert (not is_comparison(op))
 @with_name(method_name_for_op(op, commute=True))
 @coerce_numbers_to_my_dtype
 def reflected_binary_operator(self, other):
  if isinstance(self, NumericalExpression):
   (self_expr, other_expr, new_inputs) = self.build_binary_op(op, other)
   return NumExprFactor('({left}) {op} ({right})'.format(left=other_expr, right=self_expr, op=op), new_inputs, dtype=binop_return_dtype(op, other.dtype, self.dtype))
  elif isinstance(other, Number):
   return NumExprFactor('{constant} {op} x_0'.format(op=op, constant=other), binds=(self,), dtype=binop_return_dtype(op, other.dtype, self.dtype))
  raise BadBinaryOperator(op, other, self)
 return reflected_binary_operator

def reflected_binary_operator ( op ) : assert ( not is_comparison ( op ) ) @ with_name ( method_name_for_op ( op , commute = True ) ) @ coerce_numbers_to_my_dtype def reflected_binary_operator ( self , other ) : if isinstance ( self , NumericalExpression ) : ( self_expr , other_expr , new_inputs ) = self . build_binary_op ( op , other ) return NumExprFactor ( '({left}) {op} ({right})' . format ( left = other_expr , right = self_expr , op = op ) , new_inputs , dtype = binop_return_dtype ( op , other . dtype , self . dtype ) ) elif isinstance ( other , Number ) : return NumExprFactor ( '{constant} {op} x_0' . format ( op = op , constant = other ) , binds = ( self , ) , dtype = binop_return_dtype ( op , other . dtype , self . dtype ) ) raise BadBinaryOperator ( op , other , self ) return reflected_binary_operator
factory function for making binary operator methods on a factor .