def _arg_to_expr(arg): if arg is None: return "[]" # empty list if isinstance(arg, ExprNode): return arg._get_ast_str(False) if isinstance(arg, ASTId): return str(arg) if isinstance(arg, (list, tuple, range)): return "[%s]" % " ".join(repr2(x) for x in arg) if isinstance(arg, slice): start = 0 if arg.start is None else arg.start stop = float("nan") if arg.stop is None else arg.stop step = 1 if arg.step is None else arg.step assert start >= 0 and step >= 1 and (math.isnan(stop) or stop >= start + step) if step == 1: return "[%d:%s]" % (start, str(stop - start)) else: return "[%d:%s:%d]" % ( start, str((stop - start + step - 1) // step), step) if isinstance(arg, ModelBase): return arg.model_id # Number representation without Py2 L suffix enforced if isinstance(arg, numbers.Integral): return repr2(arg).strip('L') return repr2(arg)
def _arg_to_expr(arg): if arg is None: return "[]" # empty list if isinstance(arg, ExprNode): return arg._get_ast_str(False) if isinstance(arg, ASTId): return str(arg) if isinstance(arg, (list, tuple, range)): return "[%s]" % " ".join(repr2(x) for x in arg) if isinstance(arg, slice): return "[{}:{}]".format( 0 if arg.start is None else arg.start, "NaN" if (arg.stop is None or math.isnan(arg.stop)) else (arg.stop) if arg.start is None else (arg.stop - arg.start)) return repr2(arg)
def _arg_to_expr(arg): if arg is None: return "[]" # empty list if isinstance(arg, ExprNode): return arg._get_ast_str(False) if isinstance(arg, ASTId): return str(arg) if isinstance(arg, (list, tuple, range)): return "[%s]" % " ".join(repr2(x) for x in arg) if isinstance(arg, slice): start = 0 if arg.start is None else arg.start stop = float("nan") if arg.stop is None else arg.stop step = 1 if arg.step is None else arg.step assert start >= 0 and step >= 1 and (math.isnan(stop) or stop >= start + step) if step == 1: return "[%d:%s]" % (start, str(stop - start)) else: return "[%d:%s:%d]" % (start, str((stop - start + step - 1) // step), step) return repr2(arg)
def _arg_to_expr(arg): if arg is None: return "[]" # empty list if isinstance(arg, ExprNode): return arg._get_ast_str(False) if isinstance(arg, ASTId): return str(arg) if isinstance(arg, (list, tuple, range)): return "[%s]" % " ".join(repr2(x) for x in arg) if isinstance(arg, slice): start = 0 if arg.start is None else arg.start stop = float("nan") if arg.stop is None else arg.stop step = 1 if arg.step is None else arg.step assert start >= 0 and step >= 1 and (math.isnan(stop) or stop >= start + step) if step == 1: return "[%d:%s]" % (start, str(stop - start)) else: return "[%d:%s:%d]" % (start, str((stop - start + step - 1) // step), step) return repr2(arg)
def _arg_to_expr(arg): if arg is None: return "[]" # empty list if isinstance(arg, ExprNode): return arg._get_ast_str(False) if isinstance(arg, ASTId): return str(arg) if isinstance(arg, (list, tuple, range)): return "[%s]" % " ".join(repr2(x) for x in arg) if isinstance(arg, slice): start = 0 if arg.start is None else arg.start stop = float("nan") if arg.stop is None else arg.stop step = 1 if arg.step is None else arg.step assert start >= 0 and step >= 1 and (math.isnan(stop) or stop >= start + step) if step == 1: return "[%d:%s]" % (start, str(stop - start)) else: return "[%d:%s:%d]" % (start, str((stop - start + step - 1) // step), step) if isinstance(arg, ModelBase): return arg.model_id # Number representation without Py2 L suffix enforced if isinstance(arg, numbers.Integral): return repr2(arg).strip('L') return repr2(arg)