Function Coverage (HA-CA)
494189
protected String getJsFunctionInitialization(String fileName, int numFunction) {
        fileName = fileName.replace("\\", "\\\\").replace("'", "\\'");
        StringBuilder sb = new StringBuilder(format("if (! _$jscoverage['%s'].functionData) {\n", fileName));
        sb.append(format("  _$jscoverage['%s'].functionData = [];\n", fileName));
        for ( int i = 0; i < numFunction; ++i) {
            sb.append(format(initFunction, fileName, i));
        }
        sb.append("}\n");
        return sb.toString();
    }
785126
function coverage(): Result {
    $path = (string) getenv('PATH');
    $vendor = (string) realpath(trim(`{$this->composer} global config bin-dir --absolute`));
    if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path);
    return $this->_exec('coveralls var/coverage.xml');
  }
28408
function (f, a, b, fa, fc, fb, options) {
    var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15;

    options.calls = options.calls + 2;

    // Infinite or Not-a-Number function value encountered
    if (!isFinite(Q)) {
        options.warn = Math.max(options.warn, 3);
        return Q;
    }

    // Maximum function count exceeded; singularity likely
    if (options.calls > options.maxCalls) {
        options.warn = Math.max(options.warn, 2);
        return Q;
    }

    // Accuracy over this subinterval is acceptable
    if (Math.abs(Q2 - Q) <= options.tolerance) {
        return Q;
    }

    // Minimum step size reached; singularity possible
    if (Math.abs(h) < options.minStep || c === a || c === b) {
        options.warn = Math.max(options.warn, 1);
        return Q;
    }

    // Otherwise, divide the interval into two subintervals
    return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options);
}
109395
function viewCoverage(done) {
  var coveragePort = 1999;
  var mylocalhost = (argv.host) ? argv.host : 'localhost';

  connect.server({
    port: coveragePort,
    root: 'build/coverage/karma_html',
    livereload: false
  });
  opens('http://' + mylocalhost + ':' + coveragePort);
  done();
}
342452
private void qcrit( RenderedImage slope, RenderedImage ab, RandomIter trasmissivityRI, RandomIter frictionRI,
            RandomIter cohesionRI, RandomIter hsIter, RandomIter effectiveRI, RandomIter densityRI ) {
        HashMap<String, Double> regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inSlope);
        int cols = regionMap.get(CoverageUtilities.COLS).intValue();
        int rows = regionMap.get(CoverageUtilities.ROWS).intValue();

        RandomIter slopeRI = RandomIterFactory.create(slope, null);
        RandomIter abRI = RandomIterFactory.create(ab, null);

        WritableRaster qcritWR = CoverageUtilities.createWritableRaster(cols, rows, null, null, null);
        WritableRandomIter qcritIter = RandomIterFactory.createWritable(qcritWR, null);
        WritableRaster classiWR = CoverageUtilities.createWritableRaster(cols, rows, null, null, null);
        WritableRandomIter classiIter = RandomIterFactory.createWritable(classiWR, null);

        pm.beginTask("Creating qcrit map...", rows);
        for( int j = 0; j < rows; j++ ) {
            pm.worked(1);
            for( int i = 0; i < cols; i++ ) {
                double slopeValue = slopeRI.getSampleDouble(i, j, 0);
                double tanPhiValue = frictionRI.getSampleDouble(i, j, 0);
                double cohValue = cohesionRI.getSampleDouble(i, j, 0);
                double rhoValue = densityRI.getSampleDouble(i, j, 0);
                double hsValue = hsIter.getSampleDouble(i, j, 0);

                if (!isNovalue(slopeValue) && !isNovalue(tanPhiValue) && !isNovalue(cohValue) && !isNovalue(rhoValue)
                        && !isNovalue(hsValue)) {
                    if (hsValue <= EPS || slopeValue > pRock) {
                        qcritIter.setSample(i, j, 0, ROCK);
                    } else {
                        double checkUnstable = tanPhiValue + cohValue / (9810.0 * rhoValue * hsValue) * (1 + pow(slopeValue, 2));
                        if (slopeValue >= checkUnstable) {
                            /*
                             * uncond unstable
                             */
                            qcritIter.setSample(i, j, 0, 5);
                        } else {
                            double checkStable = tanPhiValue * (1 - 1 / rhoValue) + cohValue / (9810 * rhoValue * hsValue)
                                    * (1 + pow(slopeValue, 2));
                            if (slopeValue < checkStable) {
                                /*
                                 * uncond. stable
                                 */
                                qcritIter.setSample(i, j, 0, 0);
                            } else {
                                double qCrit = trasmissivityRI.getSampleDouble(i, j, 0)
                                        * sin(atan(slopeValue))
                                        / abRI.getSampleDouble(i, j, 0)
                                        * rhoValue
                                        * (1 - slopeValue / tanPhiValue + cohValue / (9810 * rhoValue * hsValue * tanPhiValue)
                                                * (1 + pow(slopeValue, 2))) * 1000;
                                qcritIter.setSample(i, j, 0, qCrit);
                                /*
                                 * see the Qcrit (critical effective
                                 * precipitation) that leads the slope to
                                 * instability (see article of Montgomery et Al,
                                 * Hydrological Processes, 12, 943-955, 1998)
                                 */
                                double value = qcritIter.getSampleDouble(i, j, 0);
                                if (value > 0 && value < 50)
                                    qcritIter.setSample(i, j, 0, 1);
                                if (value >= 50 && value < 100)
                                    qcritIter.setSample(i, j, 0, 2);
                                if (value >= 100 && value < 200)
                                    qcritIter.setSample(i, j, 0, 3);
                                if (value >= 200)
                                    qcritIter.setSample(i, j, 0, 4);
                            }
                        }
                    }
                } else {
                    qcritIter.setSample(i, j, 0, doubleNovalue);
                }
            }
        }
        pm.done();

        /*
         * build the class matrix 1=inc inst 2=inc stab 3=stab 4=instab
         * rock=presence of rock
         */
        pm.beginTask("Creating stability map...", rows);
        double Tq = 0;
        for( int j = 0; j < rows; j++ ) {
            pm.worked(1);
            for( int i = 0; i < cols; i++ ) {
                Tq = trasmissivityRI.getSampleDouble(i, j, 0) / (effectiveRI.getSampleDouble(i, j, 0) / 1000.0);
                double slopeValue = slopeRI.getSampleDouble(i, j, 0);
                double abValue = abRI.getSampleDouble(i, j, 0);
                double tangPhiValue = frictionRI.getSampleDouble(i, j, 0);
                double cohValue = cohesionRI.getSampleDouble(i, j, 0);
                double rhoValue = densityRI.getSampleDouble(i, j, 0);
                double hsValue = hsIter.getSampleDouble(i, j, 0);

                if (!isNovalue(slopeValue) && !isNovalue(abValue) && !isNovalue(tangPhiValue) && !isNovalue(cohValue)
                        && !isNovalue(rhoValue) && !isNovalue(hsValue)) {
                    if (hsValue <= EPS || slopeValue > pRock) {
                        classiIter.setSample(i, j, 0, ROCK);
                    } else {
                        double checkUncondUnstable = tangPhiValue + cohValue / (9810 * rhoValue * hsValue)
                                * (1 + pow(slopeValue, 2));
                        double checkUncondStable = tangPhiValue * (1 - 1 / rhoValue) + cohValue / (9810 * rhoValue * hsValue)
                                * (1 + pow(slopeValue, 2));
                        double checkStable = Tq
                                * sin(atan(slopeValue))
                                * rhoValue
                                * (1 - slopeValue / tangPhiValue + cohValue / (9810 * rhoValue * hsValue * tangPhiValue)
                                        * (1 + pow(slopeValue, 2)));
                        if (slopeValue >= checkUncondUnstable) {
                            classiIter.setSample(i, j, 0, 1);
                        } else if (slopeValue < checkUncondStable) {
                            classiIter.setSample(i, j, 0, 2);
                        } else if (abValue < checkStable && classiIter.getSampleDouble(i, j, 0) != 1
                                && classiIter.getSampleDouble(i, j, 0) != 2) {
                            classiIter.setSample(i, j, 0, 3);
                        } else {
                            classiIter.setSample(i, j, 0, 4);
                        }
                    }
                } else {
                    classiIter.setSample(i, j, 0, doubleNovalue);
                }
            }
        }
        pm.done();

        outQcrit = CoverageUtilities.buildCoverage("qcrit", qcritWR, regionMap, inSlope.getCoordinateReferenceSystem());
        outShalstab = CoverageUtilities.buildCoverage("classi", classiWR, regionMap, inSlope.getCoordinateReferenceSystem());

    }
340464
def add_coverage(self, qname, sname, qcover, scover=None):
        """"""
        self.alignment_coverage.loc[qname, sname] = qcover
        if scover:
            self.alignment_coverage.loc[sname, qname] = scover
198836
def setup_coverage(config, kernel, floc, output_loc=None):
    

    language = kernel.language
    if language.startswith('python'):
        # Get the pytest-cov coverage object
        cov = get_cov(config)
        if cov:
            # If present, copy the data file location used by pytest-cov
            data_file = os.path.abspath(cov.config.data_file)
        else:
            # Fall back on output_loc and current dir if not
            data_file = os.path.abspath(os.path.join(output_loc or os.getcwd(), '.coverage'))

        # Get options from pytest-cov's command line arguments:
        source = config.option.cov_source
        config_file = config.option.cov_config
        if isinstance(config_file, str) and os.path.isfile(config_file):
            config_file = os.path.abspath(config_file)

        # Copy the suffix of plugin if available
        suffix = _make_suffix(cov)
        if suffix is True:
            # Cannot merge data with autogen suffix, so turn off warning
            # for missing data in pytest-cov collector
            cov._warn_no_data = False

        # Build setup command and execute in kernel:
        cmd = _python_setup % (data_file, source, config_file, suffix)
        msg_id = kernel.kc.execute(cmd, stop_on_error=False)
        kernel.await_idle(msg_id, 60)  # A minute should be plenty to enable coverage
    else:
        config.warn(
            'C1',
            'Coverage currently not supported for language "%s".' % language,
            floc)
        return
216635
function KarmaCodeSpecsMatcher(serverPool, config) {
    this._serverPool = serverPool;
    this._config = _.merge({ karma: { waitForCoverageTime: 5 } }, config);
    this._coverageDir = path.join(config.karma.basePath, 'coverage');
}
199834
static function fromCoverage(string $coverage): self {
    $report = new static;
    $records = $report->getRecords();

    try {
      /** @var Record $record */
      $record = null;
      foreach (preg_split('/\r?\n/', $coverage) ?: [] as $line) {
        $line = trim($line);
        if (!mb_strlen($line)) continue;

        $parts = explode(':', $line);
        if (count($parts) < 2 && $parts[0] != Token::endOfRecord) throw new \DomainException('Invalid token format');

        $token = array_shift($parts);
        $data = explode(',', implode(':', $parts));
        $length = count($data);

        switch ($token) {
          case Token::testName:
            $report->setTestName($data[0]);
            break;

          case Token::sourceFile:
            $record = new Record($data[0], new FunctionCoverage, new BranchCoverage, new LineCoverage);
            break;

          case Token::functionName:
            if ($length < 2) throw new \DomainException('Invalid function name');
            if ($functions = $record->getFunctions()) $functions->getData()->append(new FunctionData($data[1], (int) $data[0]));
            break;

          case Token::functionData:
            if ($length < 2) throw new \DomainException('Invalid function data');
            if ($functions = $record->getFunctions()) foreach ($functions->getData() as $item) {
              if ($item->getFunctionName() == $data[1]) {
                $item->setExecutionCount((int) $data[0]);
                break;
              }
            }
            break;

          case Token::functionsFound:
            if ($functions = $record->getFunctions()) $functions->setFound((int) $data[0]);
            break;

          case Token::functionsHit:
            if ($functions = $record->getFunctions()) $functions->setHit((int) $data[0]);
            break;

          case Token::branchData:
            if ($length < 4) throw new \DomainException('Invalid branch data');
            if ($branches = $record->getBranches()) $branches->getData()->append(new BranchData(
              (int) $data[0],
              (int) $data[1],
              (int) $data[2],
              $data[3] == '-' ? 0 : (int) $data[3]
            ));
            break;

          case Token::branchesFound:
            if ($branches = $record->getBranches()) $branches->setFound((int) $data[0]);
            break;

          case Token::branchesHit:
            if ($branches = $record->getBranches()) $branches->setHit((int) $data[0]);
            break;

          case Token::lineData:
            if ($length < 2) throw new \DomainException('Invalid line data');
            if ($lines = $record->getLines()) $lines->getData()->append(new LineData(
              (int) $data[0],
              (int) $data[1],
              $length >= 3 ? $data[2] : ''
            ));
            break;

          case Token::linesFound:
            if ($lines = $record->getLines()) $lines->setFound((int) $data[0]);
            break;

          case Token::linesHit:
            if ($lines = $record->getLines()) $lines->setHit((int) $data[0]);
            break;

          case Token::endOfRecord:
            $records->append($record);
            break;
        }
      }
    }

    catch (\Throwable $e) {
      throw new LcovException('The coverage data has an invalid LCOV format', $coverage, -1, $e);
    }

    if (!count($records)) throw new LcovException('The coverage data is empty', $coverage);
    return $report;
  }
1152134
function () { $assertEveryCalled (function (mkay__2) {

        var twoPlusTwo   = function () { return 2 + 2 }
        var shouldBeFour = function (result) {
            $assert (result == 4)
            mkay__2 () }

        twoPlusTwo.asContinuation (shouldBeFour)
        _.asContinuation (twoPlusTwo) (shouldBeFour) }) }
1227909
def task_coverage():
    """"""
    cov = Coverage(
        [PythonPackage('import_deps', 'tests')],
        config={'branch':True,},
    )
    yield cov.all() # create task `coverage`
    yield cov.src()
474808
def coverage(self):
        """"""
        items_unk = collections.Counter()
        items_ok = collections.Counter()

        def _go_deep(obj):
            """Recursive function to find internal attributes."""
            if type(obj).__name__ in ('UnknownObject', 'UnknownAction'):
                # blatantly unknown
                items_unk[obj.name] += 1
            elif obj.name in ('DefineMorphShape2', 'ClipActions'):
                # these are incomplete, see FIXMEs in the code above
                items_unk[obj.name] += 1
            else:
                # fully parsed
                items_ok[obj.name] += 1

            for name in obj._attribs:
                attr = getattr(obj, name)
                if isinstance(attr, SWFObject):
                    _go_deep(attr)

        for tag in self.tags:
            _go_deep(tag)

        full_count = sum(items_ok.values()) + sum(items_unk.values())
        coverage = 100 * sum(items_ok.values()) / full_count
        print("Coverage is {:.1f}% of {} total items".format(coverage,
                                                             full_count))
        print("Most common parsed objects:")
        for k, v in items_ok.most_common(3):
            print("{:5d} {}".format(v, k))
        if items_unk:
            print("Most common Unknown objects")
            for k, v in items_unk.most_common(3):
                print("{:5d} {}".format(v, k))
989120
def expect_ha():
    
    ha_related_units = []
    try:
        ha_related_units = list(expected_related_units(reltype='ha'))
    except (NotImplementedError, KeyError):
        pass
    return len(ha_related_units) > 0 or config('vip') or config('dns-ha')
389632
def determine_coverage(cls, coverage_file):
        
        lines = []
        source_file = 'ERROR'
        for line in coverage_file:
            m = title_re.match(line)
            if m:
                if m.group(2) == '100':
                    return ('', [])
                source_file = m.group(1)
                continue
            m = source_re.match(line)
            if m:
                lines.append(int(m.group(1)))
                continue
            if end_re.match(line):
                break
        line_ranges = cls.make_ranges(lines)
        return (source_file, line_ranges)
66493
def use_vqsr(algs, call_file=None):
    
    from bcbio.variation import vcfutils
    vqsr_callers = set(["gatk", "gatk-haplotype"])
    vqsr_sample_thresh = 50
    vqsr_supported = collections.defaultdict(int)
    coverage_intervals = set([])
    for alg in algs:
        callers = alg.get("variantcaller")
        if isinstance(callers, six.string_types):
            callers = [callers]
        if not callers:  # no variant calling, no VQSR
            continue
        if "vqsr" in (alg.get("tools_off") or []):  # VQSR turned off
            continue
        for c in callers:
            if c in vqsr_callers:
                if "vqsr" in (alg.get("tools_on") or []):  # VQSR turned on:
                    vqsr_supported[c] += 1
                    coverage_intervals.add("genome")
                # Do not try VQSR for gVCF inputs
                elif call_file and vcfutils.is_gvcf_file(call_file):
                    pass
                else:
                    coverage_intervals.add(alg.get("coverage_interval", "exome").lower())
                    vqsr_supported[c] += 1
    if len(vqsr_supported) > 0:
        num_samples = max(vqsr_supported.values())
        if "genome" in coverage_intervals or num_samples >= vqsr_sample_thresh:
            return True
    return False
1260880
function (f, context, args, description) {
  args = args || [];
  if (Package['audit-argument-checks']) {
    return Match._failIfArgumentsAreNotAllChecked(
      f, context, args, description);
  }
  return f.apply(context, args);
}
138931
def calc_coverage(ref, start, end, length, nucs):
    
    ref = ref[start - 1:end]
    bases = 0
    for pos in ref:
        for base, count in list(pos.items()):
            if base in nucs:
                bases += count
    return float(bases)/float(length)