use of org.knime.core.data.def.DoubleCell in project knime-core by knime.
the class Statistics3Table method createRow.
private DataRow createRow(final String key, final double[] array) {
int idx = 0;
DataTableSpec outSpec = createOutSpecNumeric(m_spec);
DataCell[] data = new DataCell[outSpec.getNumColumns()];
for (int i = 0; idx < data.length; i++) {
if (outSpec.getColumnSpec(idx).getName().equals(m_spec.getColumnSpec(i).getName())) {
if (Double.isNaN(array[i])) {
data[idx] = DataType.getMissingCell();
} else {
data[idx] = new DoubleCell(array[i]);
}
idx++;
}
}
return new DefaultRow(key, data);
}
use of org.knime.core.data.def.DoubleCell in project knime-core by knime.
the class Statistics3Table method createRow.
/**
* Creates a row for the transposed table.
*
* @param name The name of the column.
* @param colIdx The index of column in the computed values.
* @return The cells according to {@link #STATISTICS_SPECIFICATION}.
*/
private DataCell[] createRow(final String name, final int colIdx) {
final DataCell[] ret = new DataCell[getStatisticsSpecification().getNumColumns()];
int i = 0;
ret[i++] = new StringCell(name);
ret[i++] = m_minCells[colIdx];
ret[i++] = m_maxCells[colIdx];
ret[i++] = new DoubleCell(m_meanValues[colIdx]);
ret[i++] = new DoubleCell(Math.sqrt(m_varianceValues[colIdx]));
ret[i++] = new DoubleCell(m_varianceValues[colIdx]);
ret[i++] = new DoubleCell(m_skewness[colIdx]);
ret[i++] = new DoubleCell(m_kurtosis[colIdx]);
ret[i++] = new DoubleCell(m_sum[colIdx]);
ret[i++] = new IntCell(m_missingValueCnt[colIdx]);
ret[i++] = new IntCell(m_nanValueCnt[colIdx]);
ret[i++] = new IntCell(m_posInfinityValueCnt[colIdx]);
ret[i++] = new IntCell(m_negInfinityValueCnt[colIdx]);
ret[i++] = Double.isNaN(m_median[colIdx]) ? DataType.getMissingCell() : new DoubleCell(m_median[colIdx]);
ret[i++] = new IntCell(m_rowCount);
return ret;
}
use of org.knime.core.data.def.DoubleCell in project knime-core by knime.
the class AffineTransRowIterator method next.
/**
* {@inheritDoc}
*/
@Override
public DataRow next() {
AffineTransConfiguration config = m_transtable.getConfiguration();
int[] indices = m_transtable.getIndicesInConfiguration();
double[] scales = config.getScales();
double[] translations = config.getTranslations();
double[] min = config.getMin();
double[] max = config.getMax();
final DataRow in = m_it.next();
final DataCell[] cells = new DataCell[in.getNumCells()];
for (int i = 0; i < cells.length; i++) {
final DataCell oldCell = in.getCell(i);
if (oldCell.isMissing() || indices[i] == -1) {
cells[i] = oldCell;
} else {
int index = indices[i];
double interval = max[index] - min[index];
double oldDouble = ((DoubleValue) oldCell).getDoubleValue();
double newDouble = scales[index] * oldDouble + translations[index];
if (!Double.isNaN(min[index])) {
if (newDouble < min[index]) {
if ((min[index] - newDouble) / interval < AffineTransTable.VERY_SMALL) {
newDouble = min[index];
} else {
m_transtable.setErrorMessage("Normalized value is out of bounds." + " Original value: " + oldDouble + " Transformed value: " + newDouble + " Lower Bound: " + min[index]);
}
}
}
if (!Double.isNaN(max[index])) {
if (newDouble > max[index]) {
if ((newDouble - max[index]) / interval < AffineTransTable.VERY_SMALL) {
newDouble = max[index];
} else {
m_transtable.setErrorMessage("Normalized value is out of bounds." + " Original value: " + oldDouble + " Transformed value: " + newDouble + " Upper Bound: " + max[index]);
}
}
}
cells[i] = new DoubleCell(newDouble);
}
}
return new DefaultRow(in.getKey(), cells);
}
use of org.knime.core.data.def.DoubleCell in project knime-core by knime.
the class VariableToTable2NodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
DataTableSpec spec = createOutSpec();
BufferedDataContainer cont = exec.createDataContainer(spec);
List<Pair<String, FlowVariable.Type>> vars = getVariablesOfInterest();
DataCell[] specs = new DataCell[vars.size()];
List<String> lostVariables = new ArrayList<String>();
for (int i = 0; i < vars.size(); i++) {
Pair<String, FlowVariable.Type> c = vars.get(i);
String name = c.getFirst();
// fallback
DataCell cell = DataType.getMissingCell();
switch(c.getSecond()) {
case DOUBLE:
try {
double dValue = peekFlowVariableDouble(c.getFirst());
cell = new DoubleCell(dValue);
} catch (NoSuchElementException e) {
lostVariables.add(name + " (Double)");
}
break;
case INTEGER:
try {
int iValue = peekFlowVariableInt(c.getFirst());
cell = new IntCell(iValue);
} catch (NoSuchElementException e) {
lostVariables.add(name + " (Integer)");
}
break;
case STRING:
try {
String sValue = peekFlowVariableString(c.getFirst());
sValue = sValue == null ? "" : sValue;
cell = new StringCell(sValue);
} catch (NoSuchElementException e) {
lostVariables.add(name + " (String)");
}
break;
}
specs[i] = cell;
}
cont.addRowToTable(new DefaultRow(m_rowID.getStringValue(), specs));
cont.close();
return new BufferedDataTable[] { cont.getTable() };
}
use of org.knime.core.data.def.DoubleCell in project knime-core by knime.
the class DayRangeOperator method getResultInternal.
/**
* {@inheritDoc}
*/
@Override
protected DataCell getResultInternal() {
final DateAndTimeValue min = getMin();
final DateAndTimeValue max = getMax();
if (min == null || max == null) {
return DataType.getMissingCell();
}
final long range = max.getUTCTimeInMillis() - min.getUTCTimeInMillis();
if (range == 0) {
return new DoubleCell(0);
}
return new DoubleCell(range / MS_PER_DAY);
}
Aggregations