Internal method used to compute the radius (half-side-length) for each
    ball (cube) used in :class:`RadFriends` (:class:`SupFriends`) using
    leave-one-out (LOO) cross-validation.
324931
def _friends_leaveoneout_radius(points, ftype):
    """"""

    # Construct KDTree to enable quick nearest-neighbor lookup for
    # our resampled objects.
    kdtree = spatial.KDTree(points)

    if ftype == 'balls':
        # Compute radius to two nearest neighbors (self + neighbor).
        dists, ids = kdtree.query(points, k=2, eps=0, p=2)
    elif ftype == 'cubes':
        # Compute half-side-length to two nearest neighbors (self + neighbor).
        dists, ids = kdtree.query(points, k=2, eps=0, p=np.inf)

    dist = dists[:, 1]  # distances to LOO nearest neighbor

    return dist
1034015
def calc_radius_xy(self, x, y, radius_deg):
        
        # calculate ra/dec of x,y pixel
        ra_deg, dec_deg = self.pixtoradec(x, y)

        # Calculate position 1 degree from the given one
        # NOTE: this needs to add in DEC, not RA
        ra2_deg, dec2_deg = wcs.add_offset_radec(ra_deg, dec_deg,
                                                 0.0, 1.0)

        # Calculate the length of this segment--it is pixels/deg
        x2, y2 = self.radectopix(ra2_deg, dec2_deg)
        px_per_deg_e = math.sqrt(math.fabs(x2 - x)**2 + math.fabs(y2 - y)**2)

        # calculate radius based on desired radius_deg
        radius_px = px_per_deg_e * radius_deg
        return radius_px
132305
def distance_to_contact(D, alpha=1):
    

    if callable(alpha):
        distance_function = alpha
    else:
        try:
            a = np.float64(alpha)

            def distance_function(x):
                return 1 / (x ** (1 / a))
        except TypeError:
            print("Alpha parameter must be callable or an array-like")
            raise
        except ZeroDivisionError:
            raise ValueError("Alpha parameter must be non-zero")

    m = np.max(distance_function(D[D != 0]))
    M = np.zeros(D.shape)
    M[D != 0] = distance_function(D[D != 0])
    M[D == 0] = m
    return M
1198161
def facets_by_halfspace(self):
        
        if self._fbh_out is None:
            output = qhalf('FN', self.halfspaces, self.interior_point)
            facets = []
            for l in output[1:]:
                facets.append([int(i) for i in l.split()[1:]])
            self._fbh_out = facets
        return self._fbh_out
968974
def _K(self, R):
        """"""
        return self._ns * self._N / R / self._sin_alpha
951874
def xAxisIsMajor(self):
        '''
        
        '''
        return max(self.radius.x, self.radius.y) == self.radius.x
850474
def compute_radius(wcs):
    """"""

    ra, dec = wcs.wcs.crval
    img_center = SkyCoord(ra=ra * u.degree, dec=dec * u.degree)
    wcs_foot = wcs.calc_footprint()
    img_corners = SkyCoord(ra=wcs_foot[:, 0] * u.degree,
                           dec=wcs_foot[:, 1] * u.degree)
    radius = img_center.separation(img_corners).max().value

    return radius
65782
def radius(self):
        '''
        
        '''
        try:
            return self._radius
        except AttributeError:
            pass
        self._radius = Point(1, 1, 0)
        return self._radius
21550
def __skullbomb_radius(self, position):
        """"""
        #get the boundaries of the explosion
        sb_row, sb_col = position
        left = max(sb_row - 1, 0)  # standard radius or 0 if out of bounds
        right = min(sb_row + 1, 7)  # standard radius or 7 if out of bounds
        top = max(sb_col - 1, 0)
        bottom = min(sb_col + 1, 7)
        for explosion_row in xrange(left, right + 1):
            for explosion_col in xrange(top, bottom + 1):
                yield (explosion_row, explosion_col)
456732
def function(vec1, vec2)
		case @func
		when :linear
			return normalized_radius(vec1, vec2)
		when :cubic_alt
			return normalized_radius(vec1, vec2)**(1.5)
		when :thin_plate_splines
			return 0.0 if radius(vec1, vec2) == 0.0
			return normalized_radius(vec1, vec2)**2.0 * Math.log(normalized_radius(vec1, vec2))
		when :thin_plate_splines_alt
			rnorm = ((@r0.prod.abs)**(2.0/@r0.size)*(((vec1-vec2).square / @r0.square).sum + 1.0))
			return rnorm * Math.log(rnorm)
		when :multiquadratic
# 			return Math.sqrt(radius(vec1, vec2)**2 + Math.sqrt(@r0.square.sum))
			(@r0.prod.abs)**(1.0/@r0.size)*Math.sqrt(((vec1-vec2).square / @r0.square).sum + 1.0)
		when :inverse_multiquadratic
			1.0 / ((@r0.prod.abs)**(1.0/@r0.size)*Math.sqrt(((vec1-vec2).square / @r0.square).sum + 1.0))
		when :cubic
			((@r0.prod.abs)**(2.0/@r0.size)*(((vec1-vec2).square / @r0.square).sum + 1.0))**(1.5)
# 			invs = ((vec1-vec2).square + @r0.square).sqrt**(-1)
# 			invs.sum
# 				p @ro
# 			return 1.0 / Math.sqrt(radius(vec1, vec2)**2 + Math.sqrt(@r0.square.sum))
# 		when :inverse_multiquadratic
# # 				p @ro
# 			return 1.0 / Math.sqrt(radius(vec1, vec2)**2 + Math.sqrt(@r0.square.sum))
		else
			raise ArgumentError.new("Bad radial basis function: #{@func}")
		end
	end
738515
def radius(self, angle):
        

        return (self.sma * (1. - self.eps) /
                np.sqrt(((1. - self.eps) * np.cos(angle))**2 +
                        (np.sin(angle))**2))
541691
def cublasStrsm(handle, side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb):
    
    
    status = _libcublas.cublasStrsm_v2(handle, 
                                       _CUBLAS_SIDE_MODE[side], 
                                       _CUBLAS_FILL_MODE[uplo], 
                                       _CUBLAS_OP[trans], 
                                       _CUBLAS_DIAG[diag], 
                                       m, n, ctypes.byref(ctypes.c_float(alpha)),
                                       int(A), lda, int(B), ldb)
    cublasCheckStatus(status)
233825
def cublasSgemm(handle, transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc):
    

    status = _libcublas.cublasSgemm_v2(handle,
                                       _CUBLAS_OP[transa],
                                       _CUBLAS_OP[transb], m, n, k, 
                                       ctypes.byref(ctypes.c_float(alpha)),
                                       int(A), lda, int(B), ldb,
                                       ctypes.byref(ctypes.c_float(beta)),
                                       int(C), ldc)
    cublasCheckStatus(status)
615049
function createNoGoCircleSpecialAttractors(x, y, radius, impactDistance, type, direction) {
  var circleSubDiv = radius * SUBDIVISE_NOGO / 20;
  for( var i = 0; i < circleSubDiv; i++ ) {
    var specialAttractor = {};
    specialAttractor.x1 = (x + radius * Math.cos(2*Math.PI / circleSubDiv * i)) * pixelRatio;
    specialAttractor.y1 = (y + radius * Math.sin(2*Math.PI / circleSubDiv * i)) * pixelRatio;
    specialAttractor.x2 = (x + radius * Math.cos(2*Math.PI / circleSubDiv * (i+1))) * pixelRatio;
    specialAttractor.y2 = (y + radius * Math.sin(2*Math.PI / circleSubDiv * (i+1))) * pixelRatio;
    specialAttractor.impactDistance = impactDistance * pixelRatio;
    specialAttractor.type = type;
    specialAttractor.direction = direction;
    specialAttractors.push(specialAttractor);
    if(DEBUG_FLAG) {
      drawHelperCircle(specialAttractor.x1, specialAttractor.y1, 1);
    }
  }

  var bbox = {
    topLeft: {
      x: (x - radius) * pixelRatio,
      y: (y - radius) * pixelRatio,
    },
    bottomRight: {
      x: (x + radius) * pixelRatio,
      y: (y + radius) * pixelRatio,
    },
  };

  specialAttractorsBoundingBoxes.push(bbox);
  noGoBBoxes.push(bbox);
}
721486
def propose_unif(self):
        """"""

        # Initialize a K-D Tree to assist nearest neighbor searches.
        if self.use_kdtree:
            kdtree = spatial.KDTree(self.live_u)
        else:
            kdtree = None

        while True:
            # Sample a point `u` from the union of N-spheres along with the
            # number of overlapping spheres `q` at point `u`.
            u, q = self.radfriends.sample(self.live_u, rstate=self.rstate,
                                          return_q=True, kdtree=kdtree)

            # Check if our sample is within the unit cube.
            if unitcheck(u, self.nonperiodic):
                # Accept the point with probability 1/q to account for
                # overlapping balls.
                if q == 1 or self.rstate.rand() < 1.0 / q:
                    break  # if successful, we're done!

        # Define the axes of the N-sphere.
        ax = np.identity(self.npdim) * self.radfriends.radius

        return u, ax
95251
def radius_cmp(a, b, offsets):
    ''''''
    diff = radius(a, offsets) - radius(b, offsets)
    if diff > 0:
        return 1
    if diff < 0:
        return -1
    return 0
1033379
def nn_dims(self, x, y, dims_x, dims_y, k=1, radius=np.inf, eps=0.0, p=2):
        
        assert len(x) == len(dims_x)
        assert len(y) == len(dims_y)
        if len(dims_x) == 0:
            kdtree = scipy.spatial.cKDTree([np.array(data_y)[np.array(dims_y) - self.dim_x] for data_y in self.data[DATA_Y]])
        elif len(dims_y) == 0:
            kdtree = scipy.spatial.cKDTree([np.array(data_x)[dims_x] for data_x in self.data[DATA_X]])
        else:
            kdtree = scipy.spatial.cKDTree([np.hstack((np.array(data_x)[dims_x], np.array(data_y)[np.array(dims_y) - self.dim_x])) for data_x,data_y in zip(self.data[DATA_X], self.data[DATA_Y])])
        dists, idxes =  kdtree.query(np.hstack((x, y)), 
                               k = k, 
                               distance_upper_bound = radius,
                               eps = eps, 
                               p = p)
        if k == 1:
            dists, idxes = np.array([dists]), [idxes]
        return dists, idxes