def replace_new_vars(expr, id_to_new_var):
 if ((expr.type == lo.VARIABLE) and (expr.data in id_to_new_var)):
  return id_to_new_var[expr.data]
 else:
  new_args = []
  for arg in expr.args:
   new_args.append(replace_new_vars(arg, id_to_new_var))
  return lo.LinOp(expr.type, expr.size, new_args, expr.data)

def replace_new_vars ( expr , id_to_new_var ) : if ( ( expr . type == lo . VARIABLE ) and ( expr . data in id_to_new_var ) ) : return id_to_new_var [ expr . data ] else : new_args = [ ] for arg in expr . args : new_args . append ( replace_new_vars ( arg , id_to_new_var ) ) return lo . LinOp ( expr . type , expr . size , new_args , expr . data )
replaces the given variables in the expression .