Compute the nearest power of two greater or equal to the input value
173109
def nextpow2(value):
    """"""
    if value >= 1:
        return 2**np.ceil(np.log2(value)).astype(int)
    elif value > 0:
        return 1
    elif value == 0:
        return 0
    else:
        raise ValueError('Value must be positive')
901111
function mpn_cmp(n1, n2, l) {
	while (l > 0) {
		var c = n1[--l] - n2[l];
		if (c != 0) {
			return c;
		}
	}
	return 0;
}
901993
def _compute(self):
        """"""
        self.min_ = self._min or 0
        self.max_ = self._max or 0
        if self.max_ - self.min_ == 0:
            self.min_ -= 1
            self.max_ += 1

        self._box.set_polar_box(0, 1, self.min_, self.max_)
1143750
def distance_to_closest(self, ps: Union["Units", List["Point2"], Set["Point2"]]) -> Union[int, float]:
        
        assert ps
        closest_distance_squared = math.inf
        for p2 in ps:
            if not isinstance(p2, Point2):
                p2 = p2.position
            distance = (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
            if distance < closest_distance_squared:
                closest_distance_squared = distance
        return closest_distance_squared ** 0.5
940611
def nearest_neighbor(x, tSet):
    
    assert isinstance(x, tuple) and isinstance(tSet, dict)
    current_key = ()
    min_d = float('inf')
    for key in tSet:
        d = distance(x, key)
        if d < min_d:
            min_d = d
            current_key = key
    return tSet[current_key]
566265
def get_bounds(self, bin_num):
        
        min_value = pow(2.0, float(bin_num) / 2.0) * self.min_value
        max_value = pow(2.0, float(bin_num + 1.0) / 2.0) * self.min_value
        return self.Bounds(min_value, max_value)
988914
def _abs_pow_ufunc(self, fi, out, p):
        """"""
        # Optimization for very common cases
        if p == 0.5:
            fi.ufuncs.absolute(out=out)
            out.ufuncs.sqrt(out=out)
        elif p == 2.0 and self.base_space.field == RealNumbers():
            fi.multiply(fi, out=out)
        else:
            fi.ufuncs.absolute(out=out)
            out.ufuncs.power(p, out=out)
55106
def _compute(self):
        """"""
        if self._min:
            self._box.ymin = min(self._min, self.zero)
        if self._max:
            self._box.ymax = max(self._max, self.zero)
        self._x_pos = [
            x / self._len for x in range(self._len + 1)
        ] if self._len > 1 else [0, 1]  # Center if only one value

        self._points(self._x_pos)

        self._x_pos = [(i + .5) / self._len for i in range(self._len)]
14744
def _min(self):
        """"""
        return (
            self.range[0] if (self.range and self.range[0] is not None) else
            (min(self._values) if self._values else None)
        )
849087
function bnCompareTo(a) {
  var r = this.s - a.s;
  if (r != 0) return r;
  var i = this.t;
  r = i - a.t;
  if (r != 0) return this.s < 0 ? -r : r;
  while (--i >= 0)
    if ((r = this[i] - a[i]) != 0) return r;
  return 0;
}
775653
def fast_exponentiation(a, b, q):
    
    assert a >= 0 and b >= 0 and q >= 1
    result = 1
    while b:
        if b % 2 == 1:
            result = (result * a) % q
        a = (a * a) % q
        b >>= 1
    return result
354729
def _compute_box(self, positive_vals, negative_vals):
        """"""
        max_ = max(
            max(positive_vals or [self.zero]),
            max(negative_vals or [self.zero])
        )

        if self.range and self.range[0] is not None:
            self._box.ymin = self.range[0]
        else:
            self._box.ymin = -max_

        if self.range and self.range[1] is not None:
            self._box.ymax = self.range[1]
        else:
            self._box.ymax = max_
555311
def canorth(S):
    ""
    E,U = np.linalg.eigh(S)
    for i in range(len(E)):
        U[:,i] = U[:,i] / np.sqrt(E[i])
    return U
1192544
function minBy (valueComputer, list) {
    var
      idx = 0,
      winner = list[idx],
      computedWinner = valueComputer(winner),

      computedCurrent;

    while (++idx < list.length) {
      computedCurrent = valueComputer(list[idx]);

      if (computedCurrent < computedWinner) {
        computedWinner = computedCurrent;
        winner = list[idx];
      }
    }

    return winner;
  }
735975
def _compute_nearest_weights_edge(idcs, ndist, variant):
    """"""
    # Get out-of-bounds indices from the norm_distances. Negative
    # means "too low", larger than or equal to 1 means "too high"
    lo = (ndist < 0)
    hi = (ndist > 1)

    # For "too low" nodes, the lower neighbor gets weight zero;
    # "too high" gets 1.
    if variant == 'left':
        w_lo = np.where(ndist <= 0.5, 1.0, 0.0)
    else:
        w_lo = np.where(ndist < 0.5, 1.0, 0.0)

    w_lo[lo] = 0
    w_lo[hi] = 1

    # For "too high" nodes, the upper neighbor gets weight zero;
    # "too low" gets 1.
    if variant == 'left':
        w_hi = np.where(ndist <= 0.5, 0.0, 1.0)
    else:
        w_hi = np.where(ndist < 0.5, 0.0, 1.0)

    w_hi[lo] = 1
    w_hi[hi] = 0

    # For upper/lower out-of-bounds nodes, we need to set the
    # lower/upper neighbors to the last/first grid point
    edge = [idcs, idcs + 1]
    edge[0][hi] = -1
    edge[1][lo] = 0

    return w_lo, w_hi, edge
1296914
function (nb, base) {
		var pow = 0;
		if (nb < 0)
			nb = -nb;
		base = base || 10;
		while (nb >= base) {
			nb = nb / base;
			++pow;
		}
		return pow;
	}
830143
def _bigger_than_zero(value: str) -> int:
    """"""
    ivalue = int(value)
    if ivalue < 0:
        raise ArgumentTypeError(
            '{} should be bigger than 0'.format(ivalue)
        )
    return ivalue