当前位置: 首页>>代码示例>>Java>>正文


Java Doubles.concat方法代码示例

本文整理汇总了Java中com.google.common.primitives.Doubles.concat方法的典型用法代码示例。如果您正苦于以下问题:Java Doubles.concat方法的具体用法?Java Doubles.concat怎么用?Java Doubles.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.primitives.Doubles的用法示例。


在下文中一共展示了Doubles.concat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: multiDimTest

import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
@Test
public void multiDimTest() throws JsonProcessingException, IOException
{
	String json = "{\"request\":{\"values\":[[1.0]]}}";

	System.out.println(json);
	ObjectMapper mapper = new ObjectMapper();
	JsonFactory factory = mapper.getFactory();
	JsonParser parser = factory.createParser(json);
	JsonNode j = mapper.readTree(parser);
	JsonNode values = j.get("request").get("values");
	
	double[][] v = mapper.readValue(values.toString(),double[][].class);
	double[] vs = Doubles.concat(v);
	int[] shape = {v.length,v[0].length };
	((ObjectNode) j.get("request")).replace("values",mapper.valueToTree(vs));
	((ObjectNode) j.get("request")).set("shape",mapper.valueToTree(shape));
	System.out.println(j.toString());
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:20,代码来源:TestJsonParse.java

示例2: getContigToMedianCRMap

import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
@VisibleForTesting
static Map<String, Double> getContigToMedianCRMap(final ReadCountCollection readCountCollection) {
    final List<String> allContigsPresent = retrieveAllContigsPresent(readCountCollection);
    final Map<String, Double> contigToMedian = new LinkedHashMap<>();
    for (String contig: allContigsPresent) {
        final ReadCountCollection oneContigReadCountCollection = readCountCollection.subsetTargets(readCountCollection.targets().stream().filter(t -> t.getContig().equals(contig)).collect(Collectors.toSet()));
        final double[] flatCounts = Doubles.concat(oneContigReadCountCollection.counts().getData());

        // Put into CRSpace
        final double[] flatCountsInCRSpace = DoubleStream.of(flatCounts).map(d -> Math.pow(2, d)).toArray();
        contigToMedian.put(contig, new Median().evaluate(flatCountsInCRSpace));
    }
    return contigToMedian;
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:15,代码来源:CoveragePoNQCUtils.java

示例3: truncateExtremeCounts

import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
/**
 * Truncates the extreme count values in the input read-count collection.
 * Values are forced to be bound by the percentile indicated with the input {@code percentile} which must be
 * in the range [0 .. 50.0]. Values under that percentile and the complementary (1 - percentile) are set to the
 * corresponding threshold value.
 *
 * <p>The imputation is done in-place, thus the input matrix is modified as a result of this call.</p>
 *
 * @param readCounts the input and output read-count matrix.
 */
public static void truncateExtremeCounts(final ReadCountCollection readCounts, final double percentile, final Logger logger) {

    final RealMatrix counts = readCounts.counts();
    final int targetCount = counts.getRowDimension();
    final int columnCount = counts.getColumnDimension();

    // Create a row major array of the counts.
    final double[] values = Doubles.concat(counts.getData());

    final Percentile bottomPercentileEvaluator = new Percentile(percentile);
    final Percentile topPercentileEvaluator = new Percentile(100.0 - percentile);
    final double bottomPercentileThreshold = bottomPercentileEvaluator.evaluate(values);
    final double topPercentileThreshold = topPercentileEvaluator.evaluate(values);
    long totalCounts = 0;
    long bottomTruncatedCounts = 0;
    long topTruncatedCounts = 0;

    for (int i = 0; i < targetCount; i++) {
        final double[] rowCounts = counts.getRow(i);
        for (int j = 0; j < columnCount; j++) {
            final double count = rowCounts[j];
            totalCounts++;
            if (count < bottomPercentileThreshold) {
                counts.setEntry(i, j, bottomPercentileThreshold);
                bottomTruncatedCounts++;
            } else if (count > topPercentileThreshold) {
                counts.setEntry(i, j, topPercentileThreshold);
                topTruncatedCounts++;
            }
        }
    }
    if (topTruncatedCounts == 0 && bottomTruncatedCounts == 0) {
        logger.info(String.format("None of the %d counts were truncated as they all fall in the non-extreme range " +
                "[%.2f, %.2f]", totalCounts, bottomPercentileThreshold, topPercentileThreshold));
    } else {
        final double truncatedPercentage = ((double)(topTruncatedCounts + bottomTruncatedCounts) / totalCounts) * 100;
        logger.info(String.format("Some counts (%d out of %d, %.2f%%) were truncated as they fall out of the " +
                "non-extreme range [%.2f, %.2f]", topTruncatedCounts + bottomTruncatedCounts, totalCounts,
                truncatedPercentage, bottomPercentileThreshold, topPercentileThreshold));
    }
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:52,代码来源:ReadCountCollectionUtils.java

示例4: getArrayCopy

import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
public double[] getArrayCopy() {
  return Doubles.concat(this.doubleArray);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:4,代码来源:DoubleVector.java


注:本文中的com.google.common.primitives.Doubles.concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。