Roll date backward to nearest end of quarter
557098
def rollback(self, date):
        """"""
        if self.onOffset(date):
            return date
        else:
            return date - QuarterEnd(month=self.month)
405656
@Override
    public void backward() {
        // TODO: This is less numerically stable than the O(n^2) method of
        // multiplying \prod_{j=1}^{i-1} x_j \prod_{j+1}^n x_j  
        Tensor x = modIn.getOutput();
        Tensor xAdj = modIn.getOutputAdj();
        Tensor tmp = new Tensor(xAdj); // copy
        tmp.fill(yAdj.getValue(0));
        tmp.multiply(y.getValue(0));
        tmp.elemDivide(x);
        xAdj.elemAdd(tmp);
    }
356640
def _roll_data(self):
        

        self.buffer.values[:, :self._window, :] = \
            self.buffer.values[:, -self._window:, :]
        self.date_buf[:self._window] = self.date_buf[-self._window:]
        self._pos = self._window
352737
function(d) {
    return d.dcEnd || (d.dcEnd =
      later.date.prev(
        later.Y.val(d),
        later.M.val(d),
        Math.min(later.dc.val(d) * 7, later.D.extent(d)[1])));
  }
706108
def month_roll(self):
        
        if self._prefix.endswith('S'):
            # MonthBegin
            roll_func = self.m_offset.rollback
        else:
            # MonthEnd
            roll_func = self.m_offset.rollforward
        return roll_func
199858
def quarter(dt):
    
    quarters = rrule.rrule(
       rrule.MONTHLY,
       bymonth = (1, 4, 7, 10),
       bysetpos = -1,
       dtstart = datetime(dt.year, 1, 1),
       count = 8
    )
    first_day = quarters.before(dt, True)
    last_day = quarters.after(dt) - relativedelta.relativedelta(days=1)
    return (first_day, last_day)
89361
def prange(ts, **kwargs):
    '''
    '''
    mi = ts.rollmin(**kwargs)
    ma = ts.rollmax(**kwargs)
    return (ts - mi)/(ma - mi)
750571
def _apply_index_days(self, i, roll):
        
        nanos = (roll % 2) * Timedelta(days=self.day_of_month - 1).value
        return i + nanos.astype('timedelta64[ns]')
1346422
def goback(self,days = 1):
    
    for i in xrange(days):
      self.raw_data.pop()
      self.data_date.pop()
      self.stock_range.pop()
      self.stock_vol.pop()
      self.stock_open.pop()
      self.stock_h.pop()
      self.stock_l.pop()
1251830
function calcBlindPositionExpiry(expiryperiod) {
    var expiryTimestamp = new Date();
    expiryTimestamp.setMinutes(expiryTimestamp.getMinutes() + expiryperiod);
    return expiryTimestamp;
  }
174667
@Override
    public void backward() {
        Tensor tmp = new Tensor(yAdj); // copy
        tmp.elemMultiply(y);
        modInX.getOutputAdj().elemAdd(tmp);
    }
918335
def backward(self):
        
        if not self.filt:
            self.forward()
        self.smth = [self.filt[-1]]
        log_trans = np.log(self.hmm.trans_mat)
        ctg = np.zeros(self.hmm.dim)  # cost to go (log-lik of y_{t+1:T} given x_t=k)
        for filt, next_ft in reversed(list(zip(self.filt[:-1], 
                                               self.logft[1:]))):
            new_ctg = np.empty(self.hmm.dim)
            for k in range(self.hmm.dim):
                new_ctg[k] = rs.log_sum_exp(log_trans[k, :] + next_ft + ctg)
            ctg = new_ctg
            smth = rs.exp_and_normalise(np.log(filt) + ctg)
            self.smth.append(smth)
        self.smth.reverse()
1093157
def aroon_down(data, period):
    
    catch_errors.check_for_period_error(data, period)
    period = int(period)

    a_down = [((period -
            list(reversed(data[idx+1-period:idx+1])).index(np.min(data[idx+1-period:idx+1]))) /
            float(period)) * 100 for idx in range(period-1, len(data))]
    a_down = fill_for_noncomputable_vals(data, a_down)
    return a_down
544887
def get_previous(self):
        """"""
        return BillingCycle.objects.filter(date_range__lt=self.date_range).order_by('date_range').last()
822191
function(d, val) {
    var wyThur = later.dw.next(later.wy.start(d), 5),
        year = later.date.prevRollover(wyThur, val, later.wy, later.Y);

    // handle case where 1st of year is last week of previous month
    if(later.wy.val(year) !== 1) {
      year = later.dw.next(year, 2);
    }

    var wyMax = later.wy.extent(year)[1],
        wyEnd = later.wy.end(year);

    val = val > wyMax ? wyMax : val || wyMax;

    return later.wy.end(later.date.next(
        later.Y.val(wyEnd),
        later.M.val(wyEnd),
        later.D.val(wyEnd) + 7 * (val-1)
      ));
  }
615609
def backwards(self, orm):
        ""
        for c in orm["contenttypes.contenttype"].objects.all():
            if c.app_label == "dublincore":
                c.app_label = "DublinCore"
                c.save()
1054349
public static function QuarterLastSecond()
    {
        $season = ceil((date('n')) / 3);
        return mktime(23, 59, 59, $season * 3, date('t', mktime(0, 0, 0, $season * 3, 1, date("Y"))), date('Y'));
    }