List of usage examples for org.apache.commons.lang ArrayUtils toObject
public static Boolean[] toObject(boolean[] array)
Converts an array of primitive booleans to objects.
From source file:parquet.column.statistics.bloomfilter.BloomFilter.java
public List<Long> getBitSet() { return Arrays.asList(ArrayUtils.toObject(bitSet.getData())); }
From source file:sf.net.experimaestro.manager.plans.GroupBy.java
@Override protected String getName() { if (indices != null) return String.format("GroupBy(%s)", Output.toString(", ", ArrayUtils.toObject(indices))); return "GroupBy"; }
From source file:sf.net.experimaestro.manager.plans.OrderBy.java
@Override protected String getName() { if (contextOrder != null) { return String.format("OrderBy (%s)", Output.toString(", ", ArrayUtils.toObject(contextOrder))); }// ww w.j a v a 2 s . c o m return String.format("OrderBy (%d contexts)", order.size()); }
From source file:sf.net.experimaestro.manager.plans.ReorderNodes.java
@Override protected String getName() { return String.format("reorder [%s]", Output.toString(", ", ArrayUtils.toObject(mapping))); }
From source file:tachyon.worker.block.TieredBlockStoreTestUtils.java
/** * Sets up a specific tier's {@link TachyonConf} for a {@link TieredBlockStore}. * * @param ordinal Ordinal value of the tier * @param tierAlias Alias of the tier/*from w w w.j a va 2s . co m*/ * @param tierPath Absolute path of the tier * @param tierCapacity Capacity of the tier */ private static void setupTachyonConfTier(int ordinal, String tierAlias, String[] tierPath, long[] tierCapacity) { Preconditions.checkNotNull(tierPath); Preconditions.checkNotNull(tierCapacity); Preconditions.checkArgument(tierPath.length == tierCapacity.length, String.format("tierPath and tierCapacity should have the same length")); sTachyonConf.set(String.format(Constants.WORKER_TIERED_STORE_LEVEL_ALIAS_FORMAT, ordinal), tierAlias); String tierPathString = StringUtils.join(tierPath, ","); sTachyonConf.set(String.format(Constants.WORKER_TIERED_STORE_LEVEL_DIRS_PATH_FORMAT, ordinal), tierPathString); String tierCapacityString = StringUtils.join(ArrayUtils.toObject(tierCapacity), ","); sTachyonConf.set(String.format(Constants.WORKER_TIERED_STORE_LEVEL_DIRS_QUOTA_FORMAT, ordinal), tierCapacityString); }
From source file:tools.descartes.wcf.forecasting.AbstractRForecaster.java
@Override public final IForecastResult forecast(final int numForecastSteps) { if (rBridge == null) return null; final ITimeSeries<Double> history = this.getTsOriginal(); final String varNameValues = RServerBridgeControl.uniqueVarname(); final String varNameModel = RServerBridgeControl.uniqueVarname(); final String varNameForecast = RServerBridgeControl.uniqueVarname(); final double[] values; List<Double> allHistory = new ArrayList<Double>(history.getValues()); // remove NullValues only if strategy is not "Croston" (forecasting for intermitted demands) if (strategy == ForecastStrategyEnum.CROST) { Double[] histValues = new Double[allHistory.size()]; histValues = allHistory.toArray(histValues); values = ArrayUtils.toPrimitive(histValues); } else {/*from ww w. j av a 2 s .c om*/ Double[] histValuesNotNull = removeNullValues(allHistory); values = ArrayUtils.toPrimitive(histValuesNotNull); } /* * 0. Assign values to temporal variable */ long startFC = System.currentTimeMillis(); AbstractRForecaster.rBridge.assign(varNameValues, values); //frequency for time series object in R --> needed for MASE calculation. AbstractRForecaster.rBridge.toTS(varNameValues, history.getFrequency()); /* * 1. Compute stochastic model for forecast */ if (this.modelFunc == null) { // In this case, the values are the model ... AbstractRForecaster.rBridge.assign(varNameModel, values); AbstractRForecaster.rBridge.toTS(varNameModel, history.getFrequency()); } else { final String[] additionalModelParams = this.getModelFuncParams(); StringBuffer params = new StringBuffer(); params.append(varNameValues); if (null != additionalModelParams) { for (String param : additionalModelParams) { params.append(","); params.append(param); } } AbstractRForecaster.rBridge.e(String.format("%s<<-%s(%s)", varNameModel, this.modelFunc, params)); } /* * 2. Perform forecast based on stochastic model */ if (this.getConfidenceLevel() == 0) { AbstractRForecaster.rBridge.e(String.format("%s<<-%s(%s,h=%d)", varNameForecast, this.forecastFunc, varNameModel, numForecastSteps)); } else { AbstractRForecaster.rBridge.e(String.format("%s<<-%s(%s,h=%d,level=c(%d))", varNameForecast, this.forecastFunc, varNameModel, numForecastSteps, this.getConfidenceLevel())); } /* * 3. Calculate Forecast Quality Metric */ double fcQuality; if (this.modelFunc == null || this.strategy == ForecastStrategyEnum.TBATS) { fcQuality = AbstractRForecaster.rBridge.eDbl("accuracy(" + varNameForecast + ")[6]"); } else { fcQuality = AbstractRForecaster.rBridge.eDbl("accuracy(" + varNameModel + ")[6]"); } final double[] lowerValues = AbstractRForecaster.rBridge.eDblArr(lowerOperationOnResult(varNameForecast)); final double[] forecastValues = AbstractRForecaster.rBridge .eDblArr(forecastOperationOnResult(varNameForecast)); final double[] upperValues = AbstractRForecaster.rBridge.eDblArr(upperOperationOnResult(varNameForecast)); // remove temporal variable: AbstractRForecaster.rBridge.e(String.format("rm(%s)", varNameModel)); AbstractRForecaster.rBridge.e(String.format("rm(%s)", varNameValues)); AbstractRForecaster.rBridge.e(String.format("rm(%s)", varNameForecast)); long endFC = System.currentTimeMillis(); ITimeSeries<Double> tsForecast = this.prepareForecastTS(); ITimeSeries<Double> tsLower; ITimeSeries<Double> tsUpper; tsForecast.appendAll(ArrayUtils.toObject(forecastValues)); if (this.getConfidenceLevel() == 0) { tsLower = tsForecast; tsUpper = tsForecast; } else { tsLower = this.prepareForecastTS(); tsLower.appendAll(ArrayUtils.toObject(lowerValues)); tsUpper = this.prepareForecastTS(); tsUpper.appendAll(ArrayUtils.toObject(upperValues)); } return new ForecastResult(tsForecast, this.getTsOriginal(), this.getConfidenceLevel(), fcQuality, tsLower, tsUpper, strategy, endFC - startFC); }
From source file:ubic.basecode.util.r.JRIClientTest.java
/** * With a continuous covariate as well a categorical one. * //from w w w . jav a2 s.c o m * @throws Exception */ public void testLinearModelB() throws Exception { if (!connected) { log.warn("Cannot load JRI, skipping test"); return; } /* * dat<-c( 3.2969, 3.1856, 3.1638, NA, 3.2342, 3.3533, 3.4347, 3.3074); a<-factor(c( "A", "A", "A", "A", "B", * "B", "B", "B" )); b<-c(1, 2, 3, 4, 5, 6, 7, 8) bar<-lm(dat ~ a + b); summary(bar) anova(bar) */ double[] data = new double[] { 3.2969, 3.1856, 3.1638, Double.NaN, 3.2342, 3.3533, 3.4347, 3.3074 }; String[] f1 = new String[] { "A", "A", "A", "A", "B", "B", "B", "B" }; List<String> fac1 = Arrays.asList(f1); double[] fac2 = new double[] { 1, 2, 3, 4, 5, 6, 7, 8 }; Map<String, List<?>> factors = new LinkedHashMap<String, List<?>>(); factors.put("foo", fac1); factors.put("bar", Arrays.asList(ArrayUtils.toObject(fac2))); LinearModelSummary lms = rc.linearModel(data, factors); Double p = lms.getMainEffectP("foo"); Double t = lms.getMainEffectT("foo")[0]; Double pp = lms.getMainEffectP("bar"); Double tt = lms.getMainEffectT("bar")[0]; Double ip = lms.getInterceptP(); Double it = lms.getInterceptT(); assertEquals(0.1586, p, 0.0001); assertEquals(0.64117305, t, 0.0001); assertEquals(0.9443, pp, 0.0001); assertEquals(0.07432241, tt, 0.0001); assertEquals(2.821526e-06, ip, 0.0001); assertEquals(38.14344686, it, 0.0001); }
From source file:ubic.gemma.analysis.preprocess.normalize.ExpressionDataQuantileNormalizer.java
/** * Quantile normalize the matrix (in place) * //ww w . j a va 2s . com * @param matrix */ public static void normalize(ExpressionDataDoubleMatrix matrix) { DoubleMatrix<CompositeSequence, BioMaterial> rawMatrix = matrix.getMatrix(); QuantileNormalizer<CompositeSequence, BioMaterial> normalizer = new QuantileNormalizer<CompositeSequence, BioMaterial>(); DoubleMatrix<CompositeSequence, BioMaterial> normalized = normalizer.normalize(rawMatrix); for (int i = 0; i < normalized.rows(); i++) { matrix.setRow(i, ArrayUtils.toObject(normalized.getRow(i))); } }
From source file:ubic.gemma.datastructure.matrix.ExpressionDataDoubleMatrix.java
@Override public Double[] getRow(Integer index) { double[] rawRow = matrix.getRow(index); return ArrayUtils.toObject(rawRow); }
From source file:ubic.gemma.persistence.service.association.coexpression.CoexpressionDaoImpl.java
@Override @Transactional//from ww w .ja v a 2 s .c o m public GeneCoexpressionNodeDegreeValueObject updateNodeDegree(Gene g, GeneCoexpressionNodeDegree nd) { Session sess = this.getSessionFactory().getCurrentSession(); List<CoexpressionValueObject> hits = this.getCoexpression(g); /* * We have to reset the support. */ GeneCoexpressionNodeDegreeValueObject gcndvo = new GeneCoexpressionNodeDegreeValueObject(nd); gcndvo.clear(); assert gcndvo.getMaxSupportNeg() == 0; for (CoexpressionValueObject hit : hits) { if (hit.isPositiveCorrelation()) { gcndvo.increment(hit.getNumDatasetsSupporting(), true); } else { gcndvo.increment(hit.getNumDatasetsSupporting(), false); } } assert gcndvo.total() == hits.size(); GeneCoexpressionNodeDegree entity = gcndvo.toEntity(); nd.setLinkCountsPositive(entity.getLinkCountsPositive()); nd.setLinkCountsNegative(entity.getLinkCountsNegative()); if (CoexpressionDaoImpl.log.isDebugEnabled()) CoexpressionDaoImpl.log.debug("gene=" + g.getId() + " pos=" + StringUtils.join(ArrayUtils.toObject(nd.getLinkCountsPositive()), " ") + " neg=" + StringUtils.join(ArrayUtils.toObject(nd.getLinkCountsNegative()), " ")); sess.update(nd); // might not be necessary, but presumption is data is stale now... this.gene2GeneCoexpressionCache.remove(g.getId()); this.geneTestedInCache.remove(g.getId()); return gcndvo; }