Which epoch are we in?
    Return integer (>=0) on success
768971
def get_epoch_number( block_height ):
    
    global EPOCHS

    if block_height <= EPOCHS[0]['end_block']:
        return 0

    for i in xrange(1, len(EPOCHS)):
        if EPOCHS[i-1]['end_block'] < block_height and (block_height <= EPOCHS[i]['end_block'] or EPOCHS[i]['end_block'] == EPOCH_NOW):
            return i

    # should never happen 
    log.error("FATAL: No epoch for %s" % block_height)
    os.abort()
880561
def value(self, t):
        """"""
        fraction = min(float(t) / max(1, self.schedule_timesteps), 1.0)
        return self.initial_p + fraction * (self.final_p - self.initial_p)
275957
def package_with_epoch(self):
        
        return u'{0}-{1}:{2}-{3}'.format(self.name,
                                         self.epoch,
                                         self.version,
                                         self.release)
960611
def epoch_info(self, training_info: TrainingInfo, global_idx: int, local_idx: int) -> EpochInfo:
        
        raise NotImplementedError
842101
def on_epoch_end(self, epoch:int, **kwargs:Any)->None:
        ""
        if self.every=="epoch": self.learn.save(f'{self.name}_{epoch}')
        else: #every="improvement"
            current = self.get_monitor_value()
            if current is not None and self.operator(current, self.best):
                print(f'Better model found at epoch {epoch} with {self.monitor} value: {current}.')
                self.best = current
                self.learn.save(f'{self.name}')
405071
def on_epoch_end(self, **kwargs):
        ""
        for p in (self.learn.model.parameters()):
                if p.requires_grad: p.grad.div_(self.acc_samples)
        if not self.drop_last: self.learn.opt.step()
        self.learn.opt.zero_grad()
1082308
def value(self):
        
        if self.opts['int']:
            return int(self.val)
        else:
            return float(self.val)
474848
def AmericanDateToEpoch(self, date_str):
    """"""
    try:
      epoch = time.strptime(date_str, "%m/%d/%Y")
      return int(calendar.timegm(epoch)) * 1000000
    except ValueError:
      return 0
146043
def __dt_to_epoch(dt):
        """"""
        # Assume UTC if no datetime is provided.
        if dt.tzinfo is None:
            dt = dt.replace(tzinfo=pytz.utc)
        epoch_start = Datetime(*MayaDT.__EPOCH_START, tzinfo=pytz.timezone('UTC'))
        return (dt - epoch_start).total_seconds()
315505
def _getFromDt(self):
        
        myNow = timezone.localtime(timezone=self.tz)
        return self.__after(myNow) or self.__before(myNow)
1063170
def now_millis(absolute=False) -> int:
  """"""
  millis = int(time.time() * 1e3)
  if absolute:
    return millis
  return millis - EPOCH_MICROS // 1000
716589
def get_number(self):
        '''
        
        '''
        number = None
        start = self.get_char('0123456789.-')
        if start:
            number = start
            finish = self.get_chars('-e0123456789.')
            if finish:
                number += finish
        if any(c in number for c in '.e'):
            return float(number)
        else:
            return int(number)
734718
def wf_epoch?(timestamp)
      return true if timestamp.is_a?(Numeric)
      raise Wavefront::Exception::InvalidTimestamp
    end
307843
def epoch_in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0,
                     minutes=0, hours=0, weeks=0):
    

    dt = time_in_a_while(days, seconds, microseconds, milliseconds, minutes,
                         hours, weeks)
    return int((dt - datetime(1970, 1, 1)).total_seconds())
559907
def _exponent(self):
        
        if self and is_finite(self):
            return mpfr.mpfr_get_exp(self)

        if not self:
            return '0'
        elif is_inf(self):
            return 'inf'
        elif is_nan(self):
            return 'nan'
        else:
            assert False, "shouldn't ever get here"
370096
function ()
	{
		for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
		{
			if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
			{
				return i;
			}
		}
		return 0;
	}
921769
def isCalibrationInProgress(self):
        
        today = DateTime()
        down_from = self.getDownFrom()
        down_to = self.getDownTo()

        return down_from <= today <= down_to