Runs refine_cand on all positive SNR candidates above threshold. Any detected at higher SNR are highlighted.
763487
def refine_cands(candsfile, threshold=0, scaledm=2.1, scalepix=2, scaleuv=1.0, chans=[], savepkl=True):
    

    # get snrs above threshold
    locs, props, d = pc.read_candidates(candsfile, snrmin=threshold, returnstate=True)

    if 'snr2' in d['features']:
        snrcol = d['features'].index('snr2')
    elif 'snr1' in d['features']:
        snrcol = d['features'].index('snr1')
    scancol = d['featureind'].index('scan')
    segmentcol = d['featureind'].index('segment')
    intcol = d['featureind'].index('int')
    dtindcol = d['featureind'].index('dtind')
    dmindcol = d['featureind'].index('dmind')
    snrs = props[:, snrcol]
    
    for (i, snr) in enumerate(snrs):
        if snr > 0:
            d, cands = refine_cand(candsfile, threshold=threshold, candnum=i,
                                   scaledm=scaledm, scalepix=scalepix, scaleuv=scaleuv, chans=chans)
            if cands:
                candlocs = np.array(cands.keys())
                candprops = np.array(cands.values())

                scan = locs[i, scancol]
                segment = locs[i, segmentcol]
                candint = locs[i, intcol]
                dmind = locs[i, dmindcol]
                dtind = locs[i, dtindcol]
                candfile = 'cands_{0}_sc{1}-seg{2}-i{3}-dm{4}-dt{5}.pkl'.format(d['fileroot'], scan, segment, candint, dmind, dtind)

                if any([candsnr > snr for candsnr in candprops[:, snrcol]]):
                    logger.info('Cand {0} had SNR {1} and refinement found a higher SNR in new ones: {2}.'.format(i, snr, candprops[:, snrcol]))
                    logger.info('Saving to {0}: {1}'.format(candfile, cands))

                    with open(candfile, 'w') as pkl:
                        pickle.dump(d, pkl, protocol=2)
                        pickle.dump((candlocs, candprops), pkl, protocol=2)
                else:
                    logger.info('Cand {0} had SNR {1}, but refinement found no improvement: {2}'.format(i, snr, candprops[:, snrcol]))
1134251
def umi_below_threshold(umi_quals, quality_encoding,  quality_filter_threshold):
    ''' '''
    below_threshold = get_below_threshold(
        umi_quals, quality_encoding, quality_filter_threshold)
    return any(below_threshold)
601825
def thresholdcands(candsfile, threshold, numberperscan=1):
    

    # read metadata and define columns of interest
    loc, prop, d = read_candidates(candsfile, returnstate=True)
    try:
        scancol = d['featureind'].index('scan')
    except ValueError:
        scancol = -1
    if 'snr2' in d['features']:
        snrcol = d['features'].index('snr2')
    elif 'snr1' in d['features']:
        snrcol = d['features'].index('snr1')

    snrs = [prop[i][snrcol] for i in range(len(prop)) if prop[i][snrcol] > threshold]

    # calculate unique list of locs of interest
    siglocs = [list(loc[i]) for i in range(len(prop)) if prop[i][snrcol] > threshold]
    siglocssort = sorted(zip([list(ll) for ll in siglocs], snrs), key=lambda stuff: stuff[1], reverse=True)

    if scancol >= 0:
        scanset = list(set([siglocs[i][scancol] for i in range(len(siglocs))]))
        candlist= []
        for scan in scanset:
            logger.debug('looking in scan %d' % scan)
            count = 0
            for sigloc in siglocssort:
                if sigloc[0][scancol] == scan:
                    logger.debug('adding sigloc %s' % str(sigloc))
                    candlist.append(sigloc)
                    count += 1
                if count >= numberperscan:
                    break
    else:
        candlist = siglocssort[:numberperscan]

    logger.debug('Returning %d cands above threshold %.1f' % (len(candlist), threshold))
    return [loc for loc,snr in candlist]
336618
def _run_nucmer(self, ref, qry, outfile):
        ''''''
        n = pymummer.nucmer.Runner(
            ref,
            qry,
            outfile,
            min_id=self.nucmer_min_id,
            min_length=self.nucmer_min_length,
            diagdiff=self.nucmer_diagdiff,
            maxmatch=True,
            breaklen=self.nucmer_breaklen,
            simplify=True,
            verbose=self.verbose
        )
        n.run()
883806
private void checkAndLimitFeatureUsedPerSplit(Frame fr) {
      int validCols = fr.numCols()-1; // for classIdx column
      if (validCols < _rfParams.num_split_features) {
        Log.info(Log.Tag.Sys.RANDF, "Limiting features from " + _rfParams.num_split_features +
                " to " + validCols + " because there are no more valid columns in the dataset");
        _rfParams.num_split_features= validCols;
      }
    }
651504
def validate(self):
        
        if self.nregions is None:
            raise TypeError("neutral regions cannot be None")
        if self.sregions is None:
            raise TypeError("selected regions cannot be None")
        if self.recregions is None:
            raise TypeError("recombination regions cannot be None")
        if self.demography is None:
            raise TypeError("demography cannot be None")
        if self.prune_selected is None:
            raise TypeError("prune_selected cannot be None")
        if self.gvalue is None:
            raise TypeError("gvalue cannot be None")
        if self.rates is None:
            raise TypeError("rates cannot be None")
1348892
def run_snr(self):
        

        if self.ecc:
            required_kwargs = {'dist_type': self.dist_type,
                               'initial_cond_type': self.initial_cond_type,
                               'ecc': True}
            input_args = [self.m1, self.m2, self.z_or_dist, self.initial_point,
                          self.eccentricity, self.observation_time]

        else:
            required_kwargs = {'dist_type': self.dist_type}
            input_args = [self.m1, self.m2, self.spin_1, self.spin_2,
                          self.z_or_dist, self.start_time, self.end_time]

        input_kwargs = {**required_kwargs,
                        **self.general,
                        **self.sensitivity_input,
                        **self.snr_input,
                        **self.parallel_input}

        self.final_dict = snr(*input_args, **input_kwargs)
        return
1344183
def check_denotation(target_values, predicted_values):
    
    # Check size
    if len(target_values) != len(predicted_values):
        return False
    # Check items
    for target in target_values:
        if not any(target.match(pred) for pred in predicted_values):
            return False
    return True
339000
def finish(self):
        ''

        self.finished = True
        self.update(self.maxval)
        self.fd.write('\n')
        if self.signal_set:
            signal.signal(signal.SIGWINCH, signal.SIG_DFL)
1118971
private void singleNodeDeletion(final double[][] mat, final BiclusterCandidate cand) {
    // Assume that cand.residue is up to date!
    while(cand.residue > delta && (cand.colcard > 2 || cand.rowcard > 2)) {
      // Store current maximum. Need final mutable, so use arrays.
      final double[] max = { Double.NEGATIVE_INFINITY };
      final int[] best = { -1, -1 };

      // Test rows
      if(cand.rowcard > 2) {
        cand.visitColumn(mat, 0, CellVisitor.SELECTED, new CellVisitor() {
          @Override
          public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
            assert (selrow);
            double rowResidue = cand.computeRowResidue(mat, row, false);
            if(max[0] < rowResidue) {
              max[0] = rowResidue;
              best[0] = row;
            }
            return false;
          }
        });
      }

      // Test columns:
      if(cand.colcard > 2) {
        cand.visitRow(mat, 0, CellVisitor.SELECTED, new CellVisitor() {
          @Override
          public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
            assert (selcol);
            double colResidue = cand.computeColResidue(mat, col);
            if(max[0] < colResidue) {
              max[0] = colResidue;
              best[1] = col;
            }
            return false;
          }
        });
      }

      if(best[1] >= 0) { // then override bestrow!
        cand.selectColumn(best[1], false);
      }
      else {
        assert (best[0] >= 0);
        cand.selectRow(best[0], false);
      }
      // TODO: incremental update could be much faster?
      cand.updateRowAndColumnMeans(mat, false);
      cand.computeMeanSquaredDeviation(mat);
      if(LOG.isDebuggingFine()) {
        LOG.debugFine("Residue in Alg 1: " + cand.residue + " " + cand.rowcard + "x" + cand.colcard);
      }
    }
  }
1330641
public void process(GrayF32 intensityImage,
						@Nullable QueueCorner candidatesMin, @Nullable QueueCorner candidatesMax,
						QueueCorner foundMin , QueueCorner foundMax ) {

		this.input = intensityImage;

		// pixels indexes larger than these should not be examined
		endBorderX = intensityImage.width-ignoreBorder;
		endBorderY = intensityImage.height-ignoreBorder;

		search.initialize(intensityImage);

		if( candidatesMin != null ) {
			foundMin.reset();
			examineMinimum(intensityImage, candidatesMin, foundMin);
		}
		if( candidatesMax != null ) {
			foundMax.reset();
			examineMaximum(intensityImage, candidatesMax, foundMax);
		}

	}
663270
def _correctArtefacts(self, image, threshold):
        '''
        
        '''
        image = np.nan_to_num(image)
        medianThreshold(image, threshold, copy=False)
        return image
5700
def _cli_check_ref_format(fmt):
    ''''''

    if fmt is None:
        return None

    fmt = fmt.lower()
    if not fmt in api.get_reference_formats():
        errstr = "Reference format '" + fmt + "' does not exist.\n"
        errstr += "For a complete list of formats, use the 'bse list-ref-formats' command"
        raise RuntimeError(errstr)

    return fmt
143456
def newsnr_threshold(self, threshold):
        
        if not self.opt.chisq_bins:
            raise RuntimeError('Chi-square test must be enabled in order to '
                               'use newsnr threshold')

        remove = [i for i, e in enumerate(self.events) if
                  ranking.newsnr(abs(e['snr']), e['chisq'] / e['chisq_dof'])
                  < threshold]
        self.events = numpy.delete(self.events, remove)
916304
private function triggerHumanReadableErrors()
    {
        $errors = libxml_get_errors();
        foreach ($errors as $error) {
            trigger_error('Line ' . $error->line . ": '" . $error->message . "' in '" . $error->file . "' -", E_USER_WARNING);
        }

        libxml_clear_errors();
    }
746531
def check_valid_rx_can_msg(result):
    
    return (result.value == ReturnCode.SUCCESSFUL) or (result.value > ReturnCode.WARNING)
656436
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01)
      AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval)
    end