Calculate the MRCA for a class pair
499146
def calculate_mrcas(self, c1 : ClassId, c2 : ClassId) -> Set[ClassId]:
        
        G = self.G
        # reflexive ancestors
        ancs1 = self._ancestors(c1) | {c1}
        ancs2 = self._ancestors(c2) | {c2}
        common_ancestors = ancs1 & ancs2
        redundant = set()
        for a in common_ancestors:
            redundant = redundant | nx.ancestors(G, a)
        return common_ancestors - redundant
250269
def get_field_mro(cls, field_name):
    """"""
    res = set()
    if hasattr(cls, '__mro__'):
        for _class in inspect.getmro(cls):
            values_ = getattr(_class, field_name, None)
            if values_ is not None:
                res = res.union(set(make_list(values_)))
    return res
976644
def calcMomentsMatlabEmpirical(params):
    """"""
    alpha = params[0]
    a = params[1:5]
    b = params[5:]
    p1 = alpha*a+(1-alpha)*b
    p21 = alpha*a[0]*a[1:]/(1-a[0])+(1-alpha)*b[0]*b[1:]/(1-b[0])
    p22 = alpha*a[1]*np.hstack((a[0],a[2:]))/(1-a[1])+(1-alpha)*b[1]*np.hstack((b[0],b[2:]))/(1-b[1])
    p23 = alpha*a[2]*np.hstack((a[:2],a[3]))/(1-a[2])+(1-alpha)*b[2]*np.hstack((b[:2],b[3]))/(1-b[2])
    p24 = alpha*a[3]*a[:3]/(1-a[3])+(1-alpha)*b[3]*b[:3]/(1-b[3])
    p3 = np.array([
        alpha*a[0]*a[2]*a[3]/(1-a[2])/(a[0]+a[1])+(1-alpha)*b[0]*b[2]*b[3]/(1-b[2])/(b[0]+b[1]),
        alpha*a[0]*a[1]*a[3]/(1-a[3])/(a[1]+a[2])+(1-alpha)*b[0]*b[1]*b[3]/(1-b[3])/(b[1]+b[2]),
        alpha*a[0]*a[1]*a[2]/(1-a[0])/(a[3]+a[2])+(1-alpha)*b[0]*b[1]*b[2]/(1-b[0])/(b[3]+b[2]),
        alpha*a[2]*a[1]*a[3]/(1-a[1])/(a[0]+a[3])+(1-alpha)*b[2]*b[1]*b[3]/(1-b[1])/(b[0]+b[3])
        ])
    return np.concatenate((p1,p21,p22,p23,p24,p3))
772988
def getUe(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
    """"""
    args = f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau
    A = getattr(adm, 'adm_e_' + classname)(*args)
    perm_keys = get_permissible_wcs(classname, f)
    if perm_keys != 'all':
        # remove disallowed rows & columns if necessary
        A = A[perm_keys][:, perm_keys]
    w, v = admeig(classname, *args)
    b0s = 11 - 2 * f / 3
    a = w / (2 * b0s)
    K = np.linalg.inv(v) @ A.T @ v
    for i in range(K.shape[0]):
        for j in range(K.shape[1]):
            if a[i] - a[j] != 1:
                K[i, j] *= (eta_s**(a[j] + 1) - eta_s**a[i]) / (a[i] - a[j] - 1)
            else:
                K[i, j] *= eta_s**a[i] * log(1 / eta_s)
    return -alpha_e / (2 * b0s * alpha_s) * v @ K @ np.linalg.inv(v)
1293364
public static int cusolverSpScsrlsqvqrHost(
        cusolverSpHandle handle, 
        int m, 
        int n, 
        int nnz, 
        cusparseMatDescr descrA, 
        Pointer csrValA, 
        Pointer csrRowPtrA, 
        Pointer csrColIndA, 
        Pointer b, 
        float tol, 
        Pointer rankA, 
        Pointer x, 
        Pointer p, 
        Pointer min_norm)
    {
        return checkResult(cusolverSpScsrlsqvqrHostNative(handle, m, n, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, b, tol, rankA, x, p, min_norm));
    }
247917
def a_over_Rs(P,R2,M2,M1=1,R1=1,planet=True):
    
    if planet:
        M2 *= REARTH/RSUN
        R2 *= MEARTH/MSUN
    return semimajor(P,M1+M2)*AU/(R1*RSUN)
1306267
def yield_pair_gradients(self, index1, index2):
        """"""
        A = self.As[index1, index2]
        B = self.Bs[index1, index2]
        distance = self.distances[index1, index2]
        yield -B*A*np.exp(-B*distance), np.zeros(3)
947785
def cublasSsyr(handle, uplo, n, alpha, x, incx, A, lda): 
    
   
    status = _libcublas.cublasSsyr_v2(handle,
                                      _CUBLAS_FILL_MODE[uplo], n, 
                                      ctypes.byref(ctypes.c_float(alpha)),
                                      int(x), incx, int(A), lda)
    cublasCheckStatus(status)
945782
def calculate(self):
      """"""
      self._calculated = True
      for name in self.transcripts:
         self.transcripts[name]['RPK'] = (float(self.transcripts[name]['count'])/float(self.transcripts[name]['length']))/float(1000)
      tot = 0.0
      for name in self.transcripts:
         tot += self.transcripts[name]['RPK']
      tot = tot/float(1000000)
      for name in self.transcripts:
         self.transcripts[name]['TPM'] = self.transcripts[name]['RPK']/tot
      """do the FPKM calculation"""
      tot = 0
      for name in self.transcripts: tot += self.transcripts[name]['count']
      tot = float(tot)/float(1000000)
      for name in self.transcripts:
         if tot > 0:
            rpm = float(self.transcripts[name]['count'])/float(tot)
            self.transcripts[name]['FPKM'] = 1000*rpm/self.transcripts[name]['length']
875481
def mtakfac(m):
  
  u, s, v = msvd(np.asarray(m, dtype=complex))
  f = np.sqrt(u.conj().T @ v.conj())
  w = v @ f
  return w, s
819851
def columns_classes(self):
        ''''''
        md = 12 / self.objects_per_row
        sm = None
        if self.objects_per_row > 2:
            sm = 12 / (self.objects_per_row / 2)
        return md, (sm or md), 12
133373
def cublasSsyr2(handle, uplo, n, alpha, x, incx, y, incy, A, lda):
    

    status = _libcublas.cublasSsyr2_v2(handle,
                                       _CUBLAS_FILL_MODE[uplo], n, 
                                       ctypes.byref(ctypes.c_float(alpha)),
                                       int(x), incx, int(y), incy,
                                       int(A), lda)
    cublasCheckStatus(status)
464855
function jenksBreaks(data, lower_class_limits, n_classes) {

        var k = data.length - 1,
            kclass = [],
            countNum = n_classes;

        // the calculation of classes will never include the upper and
        // lower bounds, so we need to explicitly set them
        kclass[n_classes] = data[data.length - 1];
        kclass[0] = data[0];

        // the lower_class_limits matrix is used as indices into itself
        // here: the `k` variable is reused in each iteration.
        while (countNum > 1) {
            kclass[countNum - 1] = data[lower_class_limits[k][countNum] - 2];
            k = lower_class_limits[k][countNum] - 1;
            countNum--;
        }

        return kclass;
    }
988933
function CSP(class1, class2) {
	var cov1 = stat.cov(class1);
	var cov2 = stat.cov(class2);
	this.V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x;
}
174259
def subject_pair_overlap(subject1, subject2, object_category=None, **kwargs):
    
    set1 = get_object_closure(subject1,
                              object_category=object_category,
                              **kwargs)
    set2 = get_object_closure(subject2,
                              object_category=object_category,
                              **kwargs)
    return len(set1.intersection(set2)), len(set1.union(set2))
423595
function calc_crc8(buf, len)
{
    var dataandcrc;
    // Generator polynomial: x**8 + x**5 + x**4 + 1 = 1001 1000 1
    var poly = 0x98800000;
    var i;

    if (len === null) return -1;
    if (len != 3) return -1;
    if (buf === null) return -1;

    // Justify the data on the MSB side. Note the poly is also
    // justified the same way.
    dataandcrc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8);
    for (i = 0; i < 24; i++) {
        if (dataandcrc & 0x80000000)
            dataandcrc ^= poly;
        dataandcrc <<= 1;
    }
    return (dataandcrc === 0);
}
1150713
def cublasSger(handle, m, n, alpha, x, incx, y, incy, A, lda):
    
    
    status = _libcublas.cublasSger_v2(handle,
                                      m, n,
                                      ctypes.byref(ctypes.c_float(alpha)),
                                      int(x), incx,
                                      int(y), incy, int(A), lda)
    cublasCheckStatus(status)