Add attributes such as count/end_time that can be present
763504
def update_attrs(self):
        
        for key, value in self._response_json.items():
            if key != 'results' and type(value) not in (list, dict):
                setattr(self, key, value)
929633
void insert_data(AttributeValue attr_val, TimeVal t)
	{
		if (size()>=max_elt)
			remove(0);
		add(new RingElt(attr_val, t));
		/*
		for (int i=0 ; i<size() ; i++)
			System.out.println(elementAt(i).toString());
		*/
	}
639754
def added=(value)
      set_attribute 'added', case value
      when Time; value.strftime '%Y-%m-%d'
      when String; value
      else
        raise ArgumentError
      end
    end
142075
def _AddAttributeToCache(self, attribute_name, value, cache):
    """"""
    # If there's another value in cache with the same timestamp, the last added
    # one takes precedence. This helps a lot in tests that use FakeTime.
    attribute_list = cache.setdefault(attribute_name, [])
    if attribute_list and attribute_list[-1].age == value.age:
      attribute_list.pop()

    attribute_list.append(value)
1078472
def add_time(self, extra_time):
        """"""
        window_start = self.parent.value('window_start') + extra_time
        self.parent.overview.update_position(window_start)
1176166
def add_has_ones(row, attrs)
      @config.has_ones.each do |name,assoc_config|
        fields = (assoc_config.fields - assoc_config.export_only_fields).map(&:to_s)
        fields.each do |f|
          csv_name = "#{name}_#{f}"
          row.has_key? csv_name or next
          (attrs[name.to_s] ||= {})[f] = row.field "#{name}_#{f}"
        end
      end
    end
165874
def _add_extra_attributes(attrs, extra_attr_map):
    
    for attr in extra_attr_map:
        if attr not in attrs:
            attrs[attr] = extra_attr_map[attr]
    return attrs
1017738
def set_endTimestamp(self,etimestamp=None):
        
        if etimestamp is None:
            import time
            etimestamp = time.strftime('%Y-%m-%dT%H:%M:%S%Z')
        self.node.set('endTimestamp',etimestamp)
673526
def GetCountStopTimes(self):
    """"""
    cursor = self._schedule._connection.cursor()
    cursor.execute(
        'SELECT count(*) FROM stop_times WHERE trip_id=?', (self.trip_id,))
    return cursor.fetchone()[0]
1281347
def dashboard(request):
    ""
    end_time = now()
    start_time = end_time - timedelta(days=7)
    defaults = {'start': start_time, 'end': end_time}

    form = DashboardForm(data=request.GET or defaults)
    if form.is_valid():
        start_time = form.cleaned_data['start']
        end_time = form.cleaned_data['end']

    # determine when tracking began
    try:
        obj = Visitor.objects.order_by('start_time')[0]
        track_start_time = obj.start_time
    except (IndexError, Visitor.DoesNotExist):
        track_start_time = now()

    # If the start_date is before tracking began, warn about incomplete data
    warn_incomplete = (start_time < track_start_time)

    # queries take `date` objects (for now)
    user_stats = Visitor.objects.user_stats(start_time, end_time)
    visitor_stats = Visitor.objects.stats(start_time, end_time)
    if TRACK_PAGEVIEWS:
        pageview_stats = Pageview.objects.stats(start_time, end_time)
    else:
        pageview_stats = None

    context = {
        'form': form,
        'track_start_time': track_start_time,
        'warn_incomplete': warn_incomplete,
        'user_stats': user_stats,
        'visitor_stats': visitor_stats,
        'pageview_stats': pageview_stats,
    }
    return render(request, 'tracking/dashboard.html', context)
661305
def _insert_data(self, name, value, timestamp, interval, config, **kwargs):
    ''''''
    conn = self._client.connect()
    if not self._update_data(name, value, timestamp, interval, config, conn):
      try:
        kwargs = {
          'name'        : name,
          'interval'    : interval,
          'i_time'      : config['i_calc'].to_bucket(timestamp),
          'value'       : value
        }
        if not config['coarse']:
          kwargs['r_time'] = config['r_calc'].to_bucket(timestamp)
        stmt = self._table.insert().values(**kwargs)
        result = conn.execute(stmt)
      except:
        # TODO: only catch IntegrityError
        if not self._update_data(name, value, timestamp, interval, config, conn):
          raise
1360576
def date_added(self, date_added):
        """"""
        self._indicator_data['dateAdded'] = self._utils.format_datetime(
            date_added, date_format='%Y-%m-%dT%H:%M:%SZ'
        )
1236910
def _create_counts(out_dts, out_dir):
    """"""
    ma, ma_mirna = _merge(out_dts)
    out_ma = op.join(out_dir, "counts.tsv")
    out_ma_mirna = op.join(out_dir, "counts_mirna.tsv")
    ma.to_csv(out_ma, sep="\t")
    ma_mirna.to_csv(out_ma_mirna, sep="\t")
    return out_ma_mirna, out_ma
949797
def _add_result(self, dict_entry, entry, dt, start_time):
    
    time_entry = {}
    time_entry['dt'] = dt
    time_entry['start_time'] = start_time
    dict_entry[entry] = time_entry
117577
def count_by_time(self):
        """"""
        out = np.empty((len(self.timesteps),), dtype=[('time', float), ('count', int)])
        for cursor,timestep in enumerate(self.timesteps):
            out[cursor] = (timestep,len([x for x in self.timeseries if x.time==timestep]))
        return out.view(np.recarray)
971440
def add(direction, count, distance)
      count = direction.downcase == 'b' ? -count.to_i : count.to_i

      case distance
      when 'd'
        @now + count
      when 'w'
        @now + count * 7
      when 'm'
        @now >> count
      when 'y'
        @now >> count * 12
      end

    end
846540
def add_attribute(self, attribute):
        
        self.attributes.append(attribute)
        return len(self.attributes)