parameters: (api, line, target_amount)
return_statement: return 'default', line
docstring: default sampling plugin
          :param api: plugin api
          :param line: data raws
          :param target_amount: target amount of points
          :return:
docstring_summary: default sampling plugin
          :param api: plugin api
          :param line: data raws
          :param target_amount: target amount of points
          :return:
docstring_tokens: default sampling plugin : param api : plugin api : param line : data raws : param target_amount : target amount of points : return :
function: def sampling(api, line, target_amount):
          """
          default sampling plugin
          :param api: plugin api
          :param line: data raws
          :param target_amount: target amount of points
          :return:
          """
          # Assume timestamp, value, range is not nullable
          if len(line) > target_amount and len(line) > 2:
              period = api.get_abstract().period  # timestamp is marked as the start time of a period
              start_time = line[0][0]
              end_time = line[-1][0]
              amount = (end_time - start_time) / period  # point amount without sampling
              aggr_period = utils.iceil(amount, target_amount) / target_amount * period
              start_time = utils.ifloor(line[0][0], aggr_period)
              tmp = {timestamp: [] for timestamp in range(start_time, end_time + period, aggr_period)}
              for point in line:
                  tmp[utils.ifloor(point[0], aggr_period)].append(point)
              line = [
                  [timestamp, utils.mean(points, lambda x: x[1]), utils.mean(points, lambda x: x[2])]
                  for timestamp, points in sorted(tmp.items())
              ]
          return 'default', line
function_tokens: def sampling ( api , line , target_amount ) : # Assume timestamp, value, range is not nullable if len ( line ) > target_amount and len ( line ) > 2 : period = api . get_abstract ( ) . period # timestamp is marked as the start time of a period start_time = line [ 0 ] [ 0 ] end_time = line [ - 1 ] [ 0 ] amount = ( end_time - start_time ) / period # point amount without sampling aggr_period = utils . iceil ( amount , target_amount ) / target_amount * period start_time = utils . ifloor ( line [ 0 ] [ 0 ] , aggr_period ) tmp = { timestamp : [ ] for timestamp in range ( start_time , end_time + period , aggr_period ) } for point in line : tmp [ utils . ifloor ( point [ 0 ] , aggr_period ) ] . append ( point ) line = [ [ timestamp , utils . mean ( points , lambda x : x [ 1 ] ) , utils . mean ( points , lambda x : x [ 2 ] ) ] for timestamp , points in sorted ( tmp . items ( ) ) ] return 'default' , line