Return the unmasked overfitting metric for a given transit depth.
554740
def unmasked(self, depth=0.01):
        """"""
        return 1 - (np.hstack(self._O2) +
                    np.hstack(self._O3) / depth) / np.hstack(self._O1)
133184
def mask(self):
        '''
        

        '''

        return np.array(list(set(np.concatenate([self.outmask, self.badmask,
                        self.transitmask, self.nanmask]))), dtype=int)
432816
def get_data(self):
        """"""
        # Count level(shortest path to root) and depth(longest path to root)
        # values for all unique GO Terms.
        data = []
        ntobj = cx.namedtuple("NtGoCnt", "Depth_Level BP_D MF_D CC_D BP_L MF_L CC_L")
        cnts = self.get_cnts_levels_depths_recs(set(self.obo.values()))
        max_val = max(max(dep for dep in cnts['depth']), max(lev for lev in cnts['level']))
        for i in range(max_val+1):
            vals = [i] + [cnts[desc][i][ns] for desc in cnts for ns in self.nss]
            data.append(ntobj._make(vals))
        return data
762163
def _normalize_missing(g):
        """"""
        g = g.astype(float)
        g[g == -1.0] = np.nan
        return g
888915
def getOverlayTransformAbsolute(self, ulOverlayHandle):
        """"""

        fn = self.function_table.getOverlayTransformAbsolute
        peTrackingOrigin = ETrackingUniverseOrigin()
        pmatTrackingOriginToOverlayTransform = HmdMatrix34_t()
        result = fn(ulOverlayHandle, byref(peTrackingOrigin), byref(pmatTrackingOriginToOverlayTransform))
        return result, peTrackingOrigin, pmatTrackingOriginToOverlayTransform
736935
def get_fc_dimensions(self, strides, kernel_sizes):
    """"""
    output_height, output_width, _ = self.hparams.problem.frame_shape
    output_steps = self.hparams.video_num_target_frames
    output_shape = np.array([output_steps, output_height, output_width])
    for curr_stride, kernel_size in zip(strides, kernel_sizes):
      output_shape = self.expected_output_shape(
          output_shape, np.array(curr_stride), 1, kernel_size)
    return np.prod(output_shape) * self.hparams.num_discriminator_filters * 8
875173
def mtr_tr_dense_local(sz):
  """"""
  hparams = mtr_tr_dense(sz)
  hparams.decoder_layers = ["local_self_att", "enc_att", "drd"] * 6
  hparams.local_attention_radius = 32
  return hparams
72176
def M(self, k, t, tips=None, gaps=None):
        """"""
        assert 0 <= k < self.ncats
        return self._models[k].M(t, tips=tips, gaps=gaps)
1139955
def fit(self):
        """"""
        self._mcmcfit = self.mcmcsetup.run()
        self._mcmcfit.burnin(self.burnin)
        dmin = min(self._mcmcfit.depth_segments)
        dmax = max(self._mcmcfit.depth_segments)
        self._thick = (dmax - dmin) / len(self.mcmcfit.depth_segments)
        self._depth = np.arange(dmin, dmax + 0.001)
        self._age_ensemble = np.array([self.agedepth(d=dx) for dx in self.depth])
644048
def robust_backtrack(self):
        

        self.L *= self.L_gamma_d
        maxiter = self.L_maxiter

        iterBTrack = 0
        linesearch = 1

        self.store_Yprev()
        while linesearch and iterBTrack < maxiter:

            t = float(1. + np.sqrt(1. + 4. * self.L * self.Tk)) / (2. * self.L)
            T = self.Tk + t
            y = (self.Tk * self.var_xprv() + t * self.ZZ) / T
            self.update_var_y(y)

            gradY = self.proximal_step()  # Given Y(f), L, this updates X(f)

            f = self.obfn_f(self.var_x())
            Dxy = self.eval_Dxy()
            Q = self.obfn_f(self.var_y()) + \
                self.eval_linear_approx(Dxy, gradY) + \
                (self.L / 2.) * np.linalg.norm(Dxy.flatten(), 2)**2

            if f <= Q:
                linesearch = 0
            else:
                self.L *= self.L_gamma_u

            iterBTrack += 1

        self.Tk = T
        self.ZZ += (t * self.L * (self.var_x() - self.var_y()))

        self.F = f
        self.Q = Q
        self.iterBTrack = iterBTrack
472808
def tanh_discrete_unbottleneck(x, hidden_size):
  """"""
  x = tf.layers.dense(x, hidden_size, name="tanh_discrete_unbottleneck")
  return x
1282085
def _get_support_mask(self):
        
        check_is_fitted(self, 'feat_list_idx')
        n_features = len(self.feature_names)
        mask = np.zeros(n_features, dtype=bool)
        mask[np.asarray(self.feat_list_idx)] = True

        return mask
772456
def estimateBackgroundLevel(img, image_is_artefact_free=False, 
                            min_rel_size=0.05, max_abs_size=11):
    '''
    
    '''

    s0,s1 = img.shape[:2]
    s = min(max_abs_size, int(max(s0,s1)*min_rel_size))
    arr = np.zeros(shape=(s0-2*s, s1-2*s), dtype=img.dtype)
    
    #fill arr:
    _spatialStd(img, arr, s)
    #most homogeneous area:
    i,j = np.unravel_index(arr.argmin(), arr.shape)
    sub = img[int(i+0.5*s):int(i+s*1.5), 
              int(j+s*0.5):int(j+s*1.5)]

    return np.median(sub)
378416
def get_regularization_penalty(self) -> Union[float, torch.Tensor]:
        
        if self._regularizer is None:
            return 0.0
        else:
            return self._regularizer(self)
223973
def _fill_masked_intensity_resid(intensity_resid, bright_pixel_mask):
        
        filled_intensity = np.zeros((intensity_resid.data.shape))
        nebins = len(intensity_resid.data)
        for i in range(nebins):
            masked = bright_pixel_mask.data[i]
            unmasked = np.invert(masked)
            mean_intensity = intensity_resid.data[i][unmasked].mean()
            filled_intensity[i] = np.where(masked, mean_intensity, intensity_resid.data[i])
        return HpxMap(filled_intensity, intensity_resid.hpx)
1189232
def DiscriminatorLayerLoss():
    '''
    '''

    data = mx.sym.Variable('data')

    label = mx.sym.Variable('label')

    data = mx.sym.Flatten(data)
    label = mx.sym.Flatten(label)

    label = mx.sym.BlockGrad(label)

    zeros = mx.sym.zeros_like(data)

    output = -GaussianLogDensity(label, data, zeros)

    dloss = mx.symbol.MakeLoss(mx.symbol.mean(output),name='lloss')

    return dloss
318814
def ma_fitplane(bma, gt=None, perc=(2,98), origmask=True):
    
    if gt is None:
        gt = [0, 1, 0, 0, 0, -1] 
    #Filter, can be useful to remove outliers
    if perc is not None:
        from pygeotools.lib import filtlib
        bma_f = filtlib.perc_fltr(bma, perc)
    else:
        bma_f = bma
    #Get indices
    x_f, y_f = get_xy_ma(bma_f, gt, origmask=origmask)
    #Regardless of desired output (origmask True or False), for fit, need to limit to valid pixels only 
    bma_f_mask = np.ma.getmaskarray(bma_f)
    #Create xyz stack, needed for SVD
    xyz = np.vstack((np.ma.array(x_f, mask=bma_f_mask).compressed(), \
            np.ma.array(y_f, mask=bma_f_mask).compressed(), bma_f.compressed())).T
    #coeff = fitPlaneSVD(xyz)
    coeff = fitPlaneLSQ(xyz)
    print(coeff)
    vals = coeff[0]*x_f + coeff[1]*y_f + coeff[2]
    resid = bma_f - vals
    return vals, resid, coeff