fetch the next set of time aligned results for all series
978515
@Override
  public void next() {
    if (!hasNext()) {
      throw new IllegalDataException("No more data");
    }
    for (final ITimeSyncedIterator sub : queries.values()) {
      sub.next(timestamp);
    }
    timestamp = nextTimestamp();
  }
1102206
def _series(self, connection, name, interval, config, buckets, **kws):
    '''
    
    '''
    fetch = kws.get('fetch')
    process_row = kws.get('process_row') or self._process_row

    rval = OrderedDict()

    if fetch:
      data = fetch( connection, self._table, name, interval, buckets )
    else:
      data = self._type_get(name, interval, buckets[0], buckets[-1])

    if config['coarse']:
      for i_bucket in buckets:
        i_key = config['i_calc'].from_bucket(i_bucket)
        i_data = data.get( i_bucket )
        if i_data:
          rval[ i_key ] = process_row( i_data[None] )
        else:
          rval[ i_key ] = self._type_no_value()
    else:
      if data:
        for i_bucket, i_data in data.items():
          i_key = config['i_calc'].from_bucket(i_bucket)
          rval[i_key] = OrderedDict()
          for r_bucket, r_data in i_data.items():
            r_key = config['r_calc'].from_bucket(r_bucket)
            if r_data:
              rval[i_key][r_key] = process_row(r_data)
            else:
              rval[i_key][r_key] = self._type_no_value()

    return rval
177736
function(results) {
        var rows = [];
        var cols = results.columns;
        
        var mapFirst = function(col) { return col.shift(); };
        
        while(cols.length > 0 && cols[0].length > 0) {
            rows.push(cols.map(mapFirst));   
        }
        
        results.rows = rows;
        return results;
    }
990846
function() {
      this.totals = [];
      this.maxTotal = 0;
      this.bounds.reset();

      if (this.series_.length === 0)
        return;

      var firstSeries = this.series_[0];
      var lastSeries = this.series_[this.series_.length - 1];

      this.bounds.addValue(firstSeries.getTimestamp(0));
      this.bounds.addValue(lastSeries.getTimestamp(lastSeries.length - 1));

      var numSeries = this.numSeries;
      this.maxTotal = -Infinity;

      // Sum the samples at each timestamp.
      // Note, this assumes that all series have all timestamps.
      for (var i = 0; i < firstSeries.length; ++i) {
        var total = 0;
        this.series_.forEach(function(series) {
          total += series.getSample(i).value;
          this.totals.push(total);
        }.bind(this));

        this.maxTotal = Math.max(total, this.maxTotal);
      }
    }
128483
def fetcher(date=datetime.today(), url_pattern=URL_PATTERN):
    
    api_url = url_pattern % date.strftime('%Y-%m-%d')

    headers = {'Referer': 'http://n.pl/program-tv'}
    raw_result = requests.get(api_url, headers=headers).json()
    return raw_result
845583
def get_pandas_series(self):
        """"""
        return pandas.Series(self.values, self.index, name=self.name)
1367873
def for_each_time_range(t)
      RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts|
        yield(ts)
      end
    end
1264274
def fetchall(self):
        
        result = []
        iterate = True
        while iterate:
            try:
                result.append(self.next())
            except StopIteration:
                iterate = False
        return result
402495
def get_timeseries(self, *args, **kwargs):
        
        import predix.data.timeseries
        ts = predix.data.timeseries.TimeSeries(*args, **kwargs)
        return ts
914722
def next(self, timeout=None):
        """"""
        try:
            apply_result = self._collector._get_result(self._idx, timeout)
        except IndexError:
            # Reset for next time
            self._idx = 0
            raise StopIteration
        except:
            self._idx = 0
            raise
        self._idx += 1
        assert apply_result.ready()
        return apply_result.get(0)
4897
def samples(self):
        """"""
        names = self.series.dimensions
        for n, offset in enumerate(self.series.offsets):
            dt = datetime.timedelta(microseconds=offset * 1000)
            d = {"ts": self.ts + dt}
            for name in names:
                d[name] = getattr(self.series, name)[n]
            yield d
1361569
def get_results_generator(future_list, timeout=None, sort_by_completed=False):
    """"""
    try:
        # python2 not support yield from
        if sort_by_completed:
            for future in as_completed(future_list, timeout=timeout):
                yield future.x
        else:
            for future in future_list:
                yield future.x
    except TimeoutError:
        return
159854
def _timeseries_component(self, series):
        
        # this is only called if the set_component function recognizes a pandas series
        # Todo: raise a warning if extrapolating from the end of the series.
        return lambda: np.interp(self.time(), series.index, series.values)
1219520
def viewTs(ts):
    
    _ts = ts
    if isinstance(ts, list):
        _ts = ts[0]
        print("It looks like you input a full time series. It's best to view one entry at a time.\n"
              "I'll show you the first entry...")
    _tmp_sort = OrderedDict()
    _tmp_sort["ROOT"] = {}
    _tmp_sort["PUBLICATION"] = {}
    _tmp_sort["GEO"] = {}
    _tmp_sort["OTHERS"] = {}
    _tmp_sort["DATA"] = {}

    # Organize the data by section
    for k,v in _ts.items():
        if not any(i == k for i in ["paleoData", "chronData", "mode", "@context"]):
            if k in ["archiveType", "dataSetName", "googleSpreadSheetKey", "metadataMD5", "tagMD5", "googleMetadataWorksheet", "lipdVersion"]:
                _tmp_sort["ROOT"][k] = v
            elif "pub" in k:
                _tmp_sort["PUBLICATION"][k] = v
            elif "geo" in k:
                _tmp_sort["GEO"][k] = v
            elif "paleoData_" in k or "chronData_" in k:
                if isinstance(v, list) and len(v) > 2:
                    _tmp_sort["DATA"][k] = "[{}, {}, {}, ...]".format(v[0], v[1], v[2])
                else:
                    _tmp_sort["DATA"][k] = v
            else:
                if isinstance(v, list) and len(v) > 2:
                    _tmp_sort["OTHERS"][k] = "[{}, {}, {}, ...]".format(v[0], v[1], v[2])
                else:
                    _tmp_sort["OTHERS"][k] = v

    # Start printing the data to console
    for k1, v1 in _tmp_sort.items():
        print("\n{}\n===============".format(k1))
        for k2, v2 in v1.items():
            print("{} : {}".format(k2, v2))

    return
361978
def next(self):
        
        step = self.raw.get('max_results', 1000)
        start = self.raw.get('start_index', 1) + step
        self.raw['start_index'] = start
        return self
371775
def get_series_events(self, id, **data):
        
        
        return self.get("/series/{0}/events/".format(id), data=data)
605274
def _construct_timeseries(self, timeseries, constraints={}):
        
        self.response_from(timeseries, constraints)
        if self.response == None:
            return None
        return {'data':self.response['data'],
                'period':self.response['period'],
                'start time':datetime.datetime.fromtimestamp(self.response['start_time']),
                'end time':datetime.datetime.fromtimestamp(self.response['end_time'])}