Terrible Fibonacci number generator.
343268
def fib(n):
    """"""
    v = n.value
    return v if v < 2 else fib2(PythonInt(v-1)) + fib(PythonInt(v-2))
572136
def recursive_index_encode(int_array, max=32767, min=-32768):
    """"""
    out_arr = []
    for curr in int_array:
        if curr >= 0 :
            while curr >= max:
                out_arr.append(max)
                curr -=  max
        else:
            while curr <= min:
                out_arr.append(min)
                curr += int(math.fabs(min))
        out_arr.append(curr)
    return out_arr
239299
function rotl_64(x, n)
	{
		if (n > 32)
		{
			n = n - 32;
			return new Int_64(
				x.lowOrder << n | x.highOrder >>> (32 - n),
				x.highOrder << n | x.lowOrder >>> (32 - n)
			);
		}
		else if (0 !== n)
		{
			return new Int_64(
				x.highOrder << n | x.lowOrder >>> (32 - n),
				x.lowOrder << n | x.highOrder >>> (32 - n)
			);
		}
		else
		{
			return x;
		}
	}
1336332
def bogus_kmers(self,count=200):
        

        POW  = math.pow
        #Build p-value inspired matrix
        #Make totals cummulative:
        # A: 0.1 C: 0.4 T:0.2 G:0.3
        #                            ->  A:0.0 C:0.1 T:0.5 G:0.7  0.0
        
        #Take bg into account:
        # We want to pick P' for each letter such that:
        #     P'/0.25  = P/Q
        # so  P'       = 0.25*P/Q
        
        m = []
        for i in range(self.width):
            _col = []
            tot   = 0.0
            for L in ACGT:
                _col.append( tot )
                tot = tot + POW(2,self.logP[i][L]) * 0.25 / self.background[L]
            _col.append(tot)
            #Renormalize
            for idx in range(len(_col)):
                _col[idx] = _col[idx] / _col[-1]
            m.append(_col)

        for p in range(0): #Was 5
            for i in range(len(m)):
                print '%6.4f  '%m[i][p],
            print

        seqs=[]
        for seqnum in range(count+1):
            f = float(seqnum)/(count+1)
            s = []
            for i in range(self.width):
                for j in range(4):
                    if (m[i][j] <= f and f < m[i][j+1]):
                        s.append(ACGT[j])
                        break
            seqs.append(''.join(s))

        del(seqs[0])
        #for i in range(count):
        #    print ">%3d\n%s"%(i,seqs[i])

        return(seqs)
291599
def erange(start, end, steps):
    
    if start == 0:
        print("Nothing you multiply zero by gives you anything but zero. Try picking something small.")
        return None
    if end == 0:
        print("It takes an infinite number of steps to get to zero. Try a small number?")
        return None

    # figure out our multiplication scale
    x = (1.0*end/start)**(1.0/(steps-1))

    # now generate the array
    ns = _n.array(list(range(0,steps)))
    a =  start*_n.power(x,ns)

    # tidy up the last element (there's often roundoff error)
    a[-1] = end

    return a
849546
def euler_totient(n):
    """"""
    result = n;
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            while n % i == 0:
                n //= i
            result -= result // i
    if n > 1:
        result -= result // n;
    return result;
510727
def _round_to_next_multiple(n, m):
    
    return n if n % m == 0 else n + m - n % m
1010480
def log_gen() -> Iterator[int]:
    
    y = 1
    while True:
        adder = max(1, math.pow(10, int(math.log10(y))))
        yield int(y)
        y = y + int(adder)
1204716
function factorial(n) {
  const start = n === 0 ? 1 : Math.abs(n)
  return start > MAX_FACTORIAL
    ? Infinity
    : Lazy.range(start, 1).reduce((x, y) => x * y)
}
1153751
def errors(self):
        

        n = self.n
        dt = self.dt
        order = self._order
        sigma = self.sigma

        error = np.zeros(order + 1)
        std = np.zeros(order + 1)

        if n == 0:
            return (error, std)

        if order == 0:
            error[0] = sigma/sqrt(n)
            std[0] = sigma/sqrt(n)

        elif order == 1:
            if n > 1:
                error[0] = sigma * sqrt(2*(2*n-1) / (n*(n+1)))
                error[1] = sigma * sqrt(12. / (n*(n*n-1)*dt*dt))
            std[0] = sigma * sqrt((2*(2*n-1)) / (n*(n+1)))
            std[1] = (sigma/dt) * sqrt(12. / (n*(n*n-1)))

        elif order == 2:
            dt2 = dt * dt

            if n >= 3:
                error[0] = sigma * sqrt(3*(3*n*n-3*n+2) / (n*(n+1)*(n+2)))
                error[1] = sigma * sqrt(12*(16*n*n-30*n+11) /
                                        (n*(n*n-1)*(n*n-4)*dt2))
                error[2] = sigma * sqrt(720/(n*(n*n-1)*(n*n-4)*dt2*dt2))

            std[0] = sigma * sqrt((3*(3*n*n - 3*n + 2)) / (n*(n+1)*(n+2)))
            std[1] = (sigma/dt) * sqrt((12*(16*n*n - 30*n + 11)) /
                                       (n*(n*n - 1)*(n*n - 4)))
            std[2] = (sigma/dt2) * sqrt(720 / (n*(n*n-1)*(n*n-4)))

        return error, std
598891
function generateSequence(start, step, increment) {
  // ex:
  // input: start: 0, step: 4, increment: 3
  // output: [ 0, 1, 4, 5, 8, 9, 12, 13 ]
  const results = []

  _.each(_.range(start, step), (i) => {
    const value = (i + increment * i)

    results.push(value, value + 1)
  })

  return results
}
795237
function rand() {
  m_z = (36969 * (m_z & 65535) + (m_z >> 16)) & mask;
  m_w = (18000 * (m_w & 65535) + (m_w >> 16)) & mask;
  let result = ((m_z << 16) + m_w) & mask;
  result /= 4294967296;
  return result + 0.5;
}
29632
def memoizing_fibonacci(n):
  """"""
  if n <= 1:
    raise ndb.Return(n)
  key = ndb.Key(FibonacciMemo, str(n))
  memo = yield key.get_async(ndb_should_cache=False)
  if memo is not None:
    assert memo.arg == n
    logging.info('memo hit: %d -> %d', n, memo.value)
    raise ndb.Return(memo.value)
  logging.info('memo fail: %d', n)
  a = yield memoizing_fibonacci(n - 1)
  b = yield memoizing_fibonacci(n - 2)
  ans = a + b
  memo = FibonacciMemo(key=key, arg=n, value=ans)
  logging.info('memo write: %d -> %d', n, memo.value)
  yield memo.put_async(ndb_should_cache=False)
  raise ndb.Return(ans)
775158
def generator(self, t):
        """"""
        self.check_fit()

        return (1.0 / self.theta) * (np.power(t, -self.theta) - 1)
1326228
function (m, n) {
      n %= 64
      if (n === 32) {
        return [m[1], m[0]]
      } else if (n < 32) {
        return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))]
      } else {
        n -= 32
        return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))]
      }
    }
1024286
def simulate(self):
        """"""
        # Simulates zero to 10 types
        return [t.simulate() for t in itertools.islice(self, random.choice(range(10)))]
21368
function nbits(x) {
	var n = 1, t;
	if ((t = x >>> 16) != 0) {
		x = t;
		n += 16;
	}
	if ((t = x >> 8) != 0) {
		x = t;
		n += 8;
	}
	if ((t = x >> 4) != 0) {
		x = t;
		n += 4;
	}
	if ((t = x >> 2) != 0) {
		x = t;
		n += 2;
	}
	if ((t = x >> 1) != 0) {
		x = t;
		n += 1;
	}
	return n;
}