List of usage examples for java.lang Double equals
public boolean equals(Object obj)
From source file:de.bund.bfr.knime.pmm.common.chart.Plotable.java
public double[][] getPoints(String paramX, String paramY, String unitX, String unitY, String transformX, String transformY, Map<String, Integer> choice) throws ConvertException { List<Double> xList = valueLists.get(paramX); List<Double> yList = valueLists.get(paramY); if (xList == null || yList == null) { return null; }/*from ww w. jav a 2 s .c om*/ List<Boolean> usedPoints = new ArrayList<>(Collections.nCopies(xList.size(), true)); if (type == BOTH_STRICT || type == DATASET_STRICT) { for (String arg : functionArguments.keySet()) { if (!arg.equals(paramX) && valueLists.containsKey(arg)) { Double fixedValue = functionArguments.get(arg).get(choice.get(arg)); List<Double> values = valueLists.get(arg); for (int i = 0; i < values.size(); i++) { if (!fixedValue.equals(values.get(i))) { usedPoints.set(i, false); } } } } if (!usedPoints.contains(true)) { return null; } } List<Point2D.Double> points = new ArrayList<>(xList.size()); for (int i = 0; i < xList.size(); i++) { Double x = xList.get(i); Double y = yList.get(i); if (x != null) { x = convertToUnit(paramX, x, unitX); x = transform(x, transformX); } if (y != null) { y = convertToUnit(paramY, y, unitY); y = transform(y, transformY); } if (usedPoints.get(i) && isValidValue(x) && isValidValue(y)) { points.add(new Point2D.Double(x, y)); } } Collections.sort(points, new Comparator<Point2D.Double>() { @Override public int compare(Point2D.Double p1, Point2D.Double p2) { return Double.compare(p1.x, p2.x); } }); double[][] pointsArray = new double[2][points.size()]; for (int i = 0; i < points.size(); i++) { pointsArray[0][i] = points.get(i).x; pointsArray[1][i] = points.get(i).y; } return pointsArray; }
From source file:com.ecofactor.qa.automation.drapi.DR_Execution_410_Test.java
/** * Checks if is end entry validated./*from www. ja v a 2s . c o m*/ * * @param details * the details * @param groupEventId * the group event id * @return true, if is end entry validated */ public boolean isEndEntryValidated(final List<ThermostatEvent> details, final Double groupEventId) { boolean endEntryValidate = false; final Double grpEventIdCompleted = groupEventId + 0.2; setLogString("Group Event ID Compleated : " + grpEventIdCompleted, true); for (ThermostatEvent thermostatEvent : details) { if ((thermostatEvent.getAction().equalsIgnoreCase(ENDEVENT)) // && // (thermostatEvent.getAlgorithmId().equals(ALGORITHMID_410)) && (thermostatEvent.getEventPhase().equals(EVENTPHASE_2)) && (thermostatEvent.getEventStatus().equalsIgnoreCase(EVENTSTATUS)) && (thermostatEvent.getEventType().equalsIgnoreCase(EVENTYPE_ALGO)) && (grpEventIdCompleted.equals(thermostatEvent.getGroupEventId()))) { endEntryValidate = true; break; } } return endEntryValidate; }
From source file:org.mobicents.servlet.restcomm.mscontrol.jsr309.Jsr309CallController.java
private void onStop(Stop message, ActorRef self, ActorRef sender) { try {/*from ww w. j a v a 2s .c o m*/ // XXX mediaGroup.stop() not implemented on Dialogic connector if (this.playing) { this.mediaGroup.getPlayer().stop(true); this.playing = Boolean.FALSE; } if (this.recording) { this.mediaGroup.getRecorder().stop(); this.recording = Boolean.FALSE; if (message.createRecord() && recordingUri != null) { Double duration; try { duration = WavUtils.getAudioDuration(recordingUri); } catch (UnsupportedAudioFileException | IOException e) { logger.error("Could not measure recording duration: " + e.getMessage(), e); duration = 0.0; } if (duration.equals(0.0)) { if (logger.isInfoEnabled()) { logger.info("Call wraping up recording. File doesn't exist since duration is 0"); } final DateTime end = DateTime.now(); duration = new Double((end.getMillis() - recordStarted.getMillis()) / 1000); } else { if (logger.isInfoEnabled()) { logger.info("Call wraping up recording. File already exists, length: " + (new File(recordingUri).length())); } } final Recording.Builder builder = Recording.builder(); builder.setSid(recordingSid); builder.setAccountSid(accountId); builder.setCallSid(callId); builder.setDuration(duration); builder.setApiVersion(runtimeSettings.getString("api-version")); StringBuilder buffer = new StringBuilder(); buffer.append("/").append(runtimeSettings.getString("api-version")).append("/Accounts/") .append(accountId.toString()); buffer.append("/Recordings/").append(recordingSid.toString()); builder.setUri(URI.create(buffer.toString())); final Recording recording = builder.build(); RecordingsDao recordsDao = daoManager.getRecordingsDao(); recordsDao.addRecording(recording); } } if (this.collecting) { this.mediaGroup.getSignalDetector().stop(); this.collecting = Boolean.FALSE; } } catch (MsControlException e) { call.tell(new MediaServerControllerError(e), self); } }
From source file:ubic.gemma.analysis.preprocess.svd.ExpressionDataSVD.java
/** * Implements method described in Skillicorn et al., "Strategies for winnowing microarray data" (also section 3.5.5 * of his book)/*from w ww .jav a2s . c o m*/ * * @param thresholdQuantile Enter 0.5 for median. Value must be > 0 and < 1. * @return a filtered matrix */ public ExpressionDataDoubleMatrix winnow(double thresholdQuantile) { if (thresholdQuantile <= 0 || thresholdQuantile >= 1) { throw new IllegalArgumentException("Threshold quantile should be a value between 0 and 1 exclusive"); } class NormCmp implements Comparable<NormCmp> { Double norm; int rowIndex; public NormCmp(int rowIndex, Double norm) { super(); this.rowIndex = rowIndex; this.norm = norm; } @Override public int compareTo(NormCmp o) { return this.norm.compareTo(o.norm); } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; NormCmp other = (NormCmp) obj; if (norm == null) { if (other.norm != null) return false; } else if (!norm.equals(other.norm)) return false; return true; } public int getRowIndex() { return rowIndex; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((norm == null) ? 0 : norm.hashCode()); return result; } } // order rows by distance from the origin. This is proportional to the 1-norm. Algebra a = new Algebra(); List<NormCmp> os = new ArrayList<NormCmp>(); for (int i = 0; i < this.expressionData.rows(); i++) { double[] row = this.getU().getRow(i); DoubleMatrix1D rom = new DenseDoubleMatrix1D(row); norm1 = a.norm1(rom); os.add(new NormCmp(i, norm1)); } Collections.sort(os); int quantileLimit = (int) Math.floor(this.expressionData.rows() * thresholdQuantile); quantileLimit = Math.max(0, quantileLimit); List<CompositeSequence> keepers = new ArrayList<CompositeSequence>(); for (int i = 0; i < quantileLimit; i++) { NormCmp x = os.get(i); CompositeSequence d = this.expressionData.getDesignElementForRow(x.getRowIndex()); keepers.add(d); } // / remove genes which are near the origin in SVD space. FIXME: make sure the missing values are still masked. return new ExpressionDataDoubleMatrix(this.expressionData, keepers); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java
/** * Create PdfTable with info on each condition of the analysis group; * * @return/* www. j a v a 2 s .c o m*/ */ //possibly reuse dRInputController's createTableModel(List<PlateCondition> processedConditions) @Override protected PdfPTable createAnalysisGroupInfoTable() { //maps log transformed conc (double) to list of velocities (double) List<DoseResponsePair> fittedData = doseResponseController.getDataToFit(false); //CONTROL HAS BEEN GIVEN A CONCENTRATION FOR FITTING PURPOSES: find control concentration (lowest) List<Double> allConcentrations = new ArrayList<>(); for (DoseResponsePair row : fittedData) { allConcentrations.add(row.getDose()); } Double controlConcentration = Collections.min(allConcentrations); // new table with 6 columns PdfPTable dataTable = new PdfPTable(6); PdfUtils.setUpPdfPTable(dataTable); // add 1st row: column names PdfUtils.addCustomizedCell(dataTable, "DRUG CONCENTRATION", boldFont); PdfUtils.addCustomizedCell(dataTable, "# TECHNICAL REPLICATES", boldFont); PdfUtils.addCustomizedCell(dataTable, "TECHNICAL REPLICATES EXCLUDED?", boldFont); PdfUtils.addCustomizedCell(dataTable, "LOWEST VELOCITY", boldFont); PdfUtils.addCustomizedCell(dataTable, "HIGHEST VELOCITY", boldFont); PdfUtils.addCustomizedCell(dataTable, "MEDIAN VELOCITY", boldFont); // for each condition get results and add a cell for (DoseResponsePair condition : fittedData) { Integer replicates = condition.getResponses().size(); String excluded; int excludedCount = 0; List<Double> velocities = condition.getResponses(); //count how many replicates were excluded for (int i = 0; i < velocities.size(); i++) { Double replicate = velocities.get(i); if (replicate == null) { excludedCount++; } } if (excludedCount == 0) { excluded = "NO"; } else { excluded = "YES, " + excludedCount; } //put log-value of the concentration back to an understandable format String concentration; Double logConc = condition.getDose(); Double transformed = Math.pow(10, logConc); //check which concentration unit is to be used //if lower than 0.1 M: use nM unit if (transformed < Math.pow(10, -7)) { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 9)) + " nM"; } //if lower than 0.1 mM: use M unit else if (transformed < Math.pow(10, -3)) { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 6)) + " M"; } //else for everything >= 1 mM use mM unit else { concentration = AnalysisUtils.roundTwoDecimals(transformed * Math.pow(10, 3)) + " mM"; } //if this is the control, replace concentration string if (logConc.equals(controlConcentration)) { concentration = "Control"; } //remove null's (excluded replicates) from velocities collection velocities.removeAll(Collections.singleton(null)); PdfUtils.addCustomizedCell(dataTable, concentration, bodyFont); PdfUtils.addCustomizedCell(dataTable, replicates.toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, excluded, bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.min(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(Collections.max(velocities)).toString(), bodyFont); PdfUtils.addCustomizedCell(dataTable, AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeMedian(velocities)).toString(), bodyFont); } return dataTable; }
From source file:org.sakaiproject.tool.gradebook.Category.java
public boolean isAssignmentsEqual() { boolean isEqual = true; Double pointsPossible = null; final List assignments = getAssignmentList(); if (assignments == null) { return isEqual; } else {/* w w w . jav a2 s. c om*/ for (final Object obj : assignments) { if (obj instanceof GradebookAssignment) { final GradebookAssignment assignment = (GradebookAssignment) obj; if (pointsPossible == null) { if (!GradebookAssignment.item_type_adjustment.equals(assignment.getItemType())) {// ignore adjustment items pointsPossible = assignment.getPointsPossible(); } } else { if (assignment.getPointsPossible() != null && !GradebookAssignment.item_type_adjustment.equals(assignment.getItemType()) // ignore adjustment items // that are not equal && !pointsPossible.equals(assignment.getPointsPossible())) { isEqual = false; return isEqual; } } } } } return isEqual; }
From source file:com.ibm.bi.dml.test.utils.TestUtils.java
/** * Compares two double values regarding tolerance t. If one or both of them * is null it is converted to 0.0.//from ww w. j a v a 2 s . c o m * * @param v1 * @param v2 * @param t * Tolerance * @return */ public static boolean compareCellValue(Double v1, Double v2, double t, boolean ignoreNaN) { if (v1 == null) v1 = 0.0; if (v2 == null) v2 = 0.0; if (ignoreNaN && (v1.isNaN() || v1.isInfinite() || v2.isNaN() || v2.isInfinite())) return true; if (v1.equals(v2)) return true; return Math.abs(v1 - v2) <= t; }
From source file:org.mobicents.servlet.restcomm.mscontrol.mgcp.MmsCallController.java
private void stopRecordingCall(Stop message) throws Exception { if (logger.isInfoEnabled()) { logger.info("Stop recording call"); }// w w w. j a va 2 s . c o m if (this.mediaGroup != null) { // Tell media group to stop recording mediaGroup.tell(message, null); this.recording = false; if (message.createRecord() && recordingUri != null) { Double duration; try { duration = WavUtils.getAudioDuration(recordingUri); } catch (UnsupportedAudioFileException | IOException e) { logger.error("Could not measure recording duration: " + e.getMessage(), e); duration = 0.0; } if (duration.equals(0.0)) { if (logger.isInfoEnabled()) { logger.info("Call wraping up recording. File doesn't exist since duration is 0"); } final DateTime end = DateTime.now(); duration = new Double((end.getMillis() - recordStarted.getMillis()) / 1000); } else { if (logger.isInfoEnabled()) { logger.info("Call wraping up recording. File already exists, length: " + (new File(recordingUri).length())); } } final Recording.Builder builder = Recording.builder(); builder.setSid(recordingSid); builder.setAccountSid(accountId); builder.setCallSid(callId); builder.setDuration(duration); builder.setApiVersion(runtimeSettings.getString("api-version")); StringBuilder buffer = new StringBuilder(); buffer.append("/").append(runtimeSettings.getString("api-version")).append("/Accounts/") .append(accountId.toString()); buffer.append("/Recordings/").append(recordingSid.toString()); builder.setUri(URI.create(buffer.toString())); final Recording recording = builder.build(); RecordingsDao recordsDao = daoManager.getRecordingsDao(); recordsDao.addRecording(recording); } } else if (logger.isInfoEnabled()) { logger.info("Tried to stop recording but group was null."); } }
From source file:gov.nih.nci.lmp.mimGpml.ImporterHelper.java
/** * Map interaction glyphs./*w ww. j a v a 2 s. c o m*/ */ private void mapInteractionGlyphs() { for (InteractionGlyphType glyph : dia.getInteractionGlyphList()) { // Diagram.InteractionGlyph.Point@visRef // Diagram.InteractionGlyph.Point@visId // Diagram.InteractionGlyph.Point@arrowHead // Diagram.InteractionGlyph.Anchor@visId PathwayElement pwElem = PathwayElement.createPathwayElement(ObjectType.LINE); pwElem.setColor(convertHexToColor(glyph.getColor())); pwElem.setGraphId(glyph.getVisId()); pwElem.setGroupRef(glyph.getGroupRef()); // TODO: Find out what comment source looks like in GPML for (String com : glyph.getCommentList()) { pwElem.addComment(com, ""); } // Set default ConnectorType to Elbow if (!glyph.getGenericPropertyList().contains("ConnectorType")) { pwElem.setConnectorType(ConnectorType.ELBOW); // Logger.log.info("Line doesn't contain ConnectorType"); } // Logger.log.info("Null connector type:" + // pwElem.getConnectorType().toString()); Logger.log.debug("InterGlyph xmlText: " + glyph.xmlText()); for (InteractionGlyphType.GenericProperty genProp : glyph.getGenericPropertyList()) { if (genProp.getKey().equals("ConnectorType")) { pwElem.setConnectorType(ConnectorType.fromName(genProp.getValue())); } else { pwElem.setDynamicProperty(genProp.getKey(), genProp.getValue()); } } Logger.log.info("Current line:" + glyph.getVisId() + "\n"); Logger.log.info("Point list:" + glyph.getPointList().size() + "\n"); List<MPoint> mPoints = new ArrayList<MPoint>(); String startGraphRef = null; String endGraphRef = null; // Map points for (int i = 0; i < glyph.getPointList().size(); i++) { InteractionGlyphType.Point pt = glyph.getPointArray(i); // Map arrowheads if (i == 0) { String arrowHead = pt.getArrowHead().toString(); String gpmlArrowHead = ImporterHelper.convertArrowHead(arrowHead); LineType lt = LineType.fromName(gpmlArrowHead); pwElem.setStartLineType(lt); Logger.log.info("startLineType:" + pt.getArrowHead().toString() + "\n"); Logger.log.info("graphRef:" + pt.getVisRef() + "\n"); startGraphRef = pt.getVisRef(); } if (i < glyph.getPointList().size()) { String arrowHead = pt.getArrowHead().toString(); String gpmlArrowHead = ImporterHelper.convertArrowHead(arrowHead); LineType lt = LineType.fromName(gpmlArrowHead); pwElem.setEndLineType(lt); Logger.log.info("endLineType:" + pt.getArrowHead().toString() + "\n"); Logger.log.info("graphRef:" + pt.getVisRef() + "\n"); endGraphRef = pt.getVisRef(); } Logger.log.info("point X:" + pt.getX() + "\n"); Logger.log.info("point Y:" + pt.getY() + "\n"); MPoint mp = pwElem.new MPoint(pt.getX(), pt.getY()); mPoints.add(mp); Double relX = new Double(Double.NaN); Double relY = new Double(Double.NaN); Logger.log.info("Importer set RelX: " + pt.getRelX()); Logger.log.info("Importer set RelY: " + pt.getRelY()); // Map RelX and RelY relX = pt.getRelX(); relY = pt.getRelY(); pwElem.setRelX(relX); pwElem.setRelY(relY); if (!relX.equals(Double.NaN) || !relY.equals(Double.NaN)) { mp.setRelativePosition(relX, relY); } else { mp.setRelativePosition(1.0, 0.5); } } pwElem.setMPoints(mPoints); if (isNotBlank(startGraphRef)) { pwElem.setStartGraphRef(startGraphRef); } if (isNotBlank(endGraphRef)) { pwElem.setEndGraphRef(endGraphRef); } Logger.log.info("Points size: " + mPoints.size()); // Map anchors for (String mimAncRef : glyph.getAnchorRefList()) { Logger.log.info("mimAncRef: " + mimAncRef); AnchorGlyphType mimAnc = getAnchorGlyphType(mimAncRef); if (mimAnc != null) { MAnchor gpmlAnc = pwElem.addMAnchor(mimAnc.getPosition()); gpmlAnc.setGraphId(mimAnc.getVisId()); if (mimAnc.getType().equals("InTrans")) { gpmlAnc.setShape(AnchorType.create("Intermolecular", true)); } if (mimAnc.getType().equals("Invisible")) { gpmlAnc.setShape(AnchorType.NONE); } } else { // TODO: This can be abstracted to other types EntityGlyphType mimEc = getExplicitComplexType(mimAncRef); MAnchor gpmlAnc = pwElem.addMAnchor(mimEc.getPosition()); gpmlAnc.setGraphId(mimEc.getVisId()); gpmlAnc.setShape(AnchorType.CIRCLE); Logger.log.debug("Imported Ec: " + mimEc.getVisId()); } } // Map PublicationXRefs List<String> mimBioRefs = mapPublicationXRefs(glyph, pwElem); pwElem.setBiopaxRefs(mimBioRefs); pw.add(pwElem); } }
From source file:ubic.gemma.core.analysis.preprocess.svd.ExpressionDataSVD.java
/** * Implements method described in Skillicorn et al., "Strategies for winnowing microarray data" (also section 3.5.5 * of his book)/*from w ww. ja v a2 s . c o m*/ * * @param thresholdQuantile Enter 0.5 for median. Value must be > 0 and < 1. * @return a filtered matrix */ public ExpressionDataDoubleMatrix winnow(double thresholdQuantile) { if (thresholdQuantile <= 0 || thresholdQuantile >= 1) { throw new IllegalArgumentException("Threshold quantile should be a value between 0 and 1 exclusive"); } class NormCmp implements Comparable<NormCmp> { private Double norm; private int rowIndex; private NormCmp(int rowIndex, Double norm) { super(); this.rowIndex = rowIndex; this.norm = norm; } @Override public int compareTo(NormCmp o) { return this.norm.compareTo(o.norm); } public int getRowIndex() { return rowIndex; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((norm == null) ? 0 : norm.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (this.getClass() != obj.getClass()) return false; NormCmp other = (NormCmp) obj; if (norm == null) { return other.norm == null; } return norm.equals(other.norm); } } // order rows by distance from the origin. This is proportional to the 1-norm. Algebra a = new Algebra(); List<NormCmp> os = new ArrayList<>(); for (int i = 0; i < this.expressionData.rows(); i++) { double[] row = this.getU().getRow(i); DoubleMatrix1D rom = new DenseDoubleMatrix1D(row); double norm1 = a.norm1(rom); os.add(new NormCmp(i, norm1)); } Collections.sort(os); int quantileLimit = (int) Math.floor(this.expressionData.rows() * thresholdQuantile); quantileLimit = Math.max(0, quantileLimit); List<CompositeSequence> keepers = new ArrayList<>(); for (int i = 0; i < quantileLimit; i++) { NormCmp x = os.get(i); CompositeSequence d = this.expressionData.getDesignElementForRow(x.getRowIndex()); keepers.add(d); } // remove genes which are near the origin in SVD space. FIXME: make sure the missing values are still masked. return new ExpressionDataDoubleMatrix(this.expressionData, keepers); }