org.apache.commons.lang.mutable.MutableFloat Java Examples
The following examples show how to use
org.apache.commons.lang.mutable.MutableFloat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReviewDataProvider.java From review-board-idea-plugin with Apache License 2.0 | 6 votes |
public void createReview(final Review reviewRequest, final List<Review.File.Comment> comments, String reviewComment, final Progress progress) throws Exception { final RBReview review = client.createReviewApi(reviewRequest.id, null); final MutableFloat progressF = new MutableFloat(0f); for (final Review.File.Comment comment : comments) { progress.progress("Updating comment", progressF.floatValue()); client.createDiffComment(reviewRequest.id, String.valueOf(review.review.id), comment.file.fileId, comment.firstLine, comment.numberOfLines, comment.text, comment.issueOpened); progressF.setValue(progressF.floatValue() + 1.0f / (comments.size() - 1)); } progress.progress("Making review public", progressF.floatValue()); client.updateReviewApi(reviewRequest.id, String.valueOf(review.review.id), true, reviewComment, null); progress.progress("Review Completed", 1); }
Example #2
Source File: SAMRecordUtils.java From abra2 with MIT License | 5 votes |
private static Pair<String, String> consensusSeq(String s1, String s2, String qual1, String qual2, int maxMismatches, MutableFloat mismatchFrac) { StringBuffer consensus = new StringBuffer(); StringBuffer consensusQual = new StringBuffer(); int numMismatches = 0; for (int i=0; i<s1.length(); i++) { if (s1.charAt(i) != s2.charAt(i)) { numMismatches += 1; if (numMismatches > maxMismatches) { return null; } else { if (qual1.charAt(i) >= qual2.charAt(i) + 10) { consensus.append(s1.charAt(i)); consensusQual.append(qual1.charAt(i)); } else if (qual2.charAt(i) >= qual1.charAt(i) + 10) { consensus.append(s2.charAt(i)); consensusQual.append(qual2.charAt(i)); } else { consensus.append('N'); consensusQual.append('!'); } } } else { consensus.append(s1.charAt(i)); consensusQual.append((char) Math.max(qual1.charAt(i), qual2.charAt(i))); } } mismatchFrac.setValue((float) numMismatches / (float) s1.length()); return new Pair<String,String>(consensus.toString(), consensusQual.toString()); }
Example #3
Source File: RegressionAdmmTrain.java From ml-ease with Apache License 2.0 | 5 votes |
private void updateLogLikBestModel(JobConf conf, int niter, Map<String, LinearModel> z, String testPath, boolean ignoreValue, MutableFloat bestTestLoglik, String outBasePath, int numClickReplicates) throws IOException { Map<String, Double> loglik; loglik = testloglik(conf, z, testPath, 1, ignoreValue); AvroHdfsFileWriter<GenericRecord> writer = new AvroHdfsFileWriter<GenericRecord>(conf, outBasePath + "/sample-test-loglik/iteration-"+niter +".avro", SampleTestLoglik.SCHEMA$); DataFileWriter<GenericRecord> testRecordWriter = writer.get(); for (String k : z.keySet()) { GenericData.Record valuemap = new GenericData.Record(SampleTestLoglik.SCHEMA$); valuemap.put("iter", niter); valuemap.put("testLoglik", loglik.get(k).floatValue()); valuemap.put("lambda", k); testRecordWriter.append(valuemap); _logger.info("Sample test loglik for lambda=" + k + " is: " + String.valueOf(loglik.get(k))); // output best model up to now if (loglik.get(k) > bestTestLoglik.floatValue() && niter>0) { String bestModelPath = outBasePath + "/best-model/best-iteration-" + niter + ".avro"; FileSystem fs = FileSystem.get(conf); fs.delete(new Path(outBasePath + "/best-model"), true); LinearModelUtils.writeLinearModel(conf, bestModelPath, z.get(k), k); bestTestLoglik.setValue(loglik.get(k).floatValue()); } } testRecordWriter.close(); }
Example #4
Source File: ReviewDataProvider.java From review-board-idea-plugin with Apache License 2.0 | 4 votes |
public List<Review.File> files(final Review review, final Progress progress) throws Exception { List<Review.File> result = new ArrayList<>(); final List<Future> futures = new CopyOnWriteArrayList<>(); final MutableFloat progressF = new MutableFloat(0f); final RBDiffList diffList = client.diffListApi(review.id); if (diffList.total_results > 0) { final String revision = String.valueOf(diffList.diffs[0].revision); final RBFileDiff fileDiff = client.fileDiffApi(review.id, revision); for (final RBFileDiff.File file : fileDiff.files) { final Review.File diffFile = new Review.File(); diffFile.fileId = file.id; diffFile.srcFileName = file.source_file; diffFile.dstFileName = file.dest_file; diffFile.sourceRevision = file.source_revision; diffFile.revision = revision; futures.add(ApplicationManager.getApplication().executeOnPooledThread( new Runnable() { @Override public void run() { progress.progress("Loading file contents " + FilenameUtils.getName(diffFile.srcFileName), progressF.floatValue()); diffFile.srcFileContents = client.contents(file.links.original_file.href); progressF.setValue(progressF.floatValue() + 1.0f / diffList.total_results); progress.progress("Completed loading contents", progressF.floatValue()); } } )); futures.add(ApplicationManager.getApplication().executeOnPooledThread( new Runnable() { @Override public void run() { progress.progress("Loading file contents " + FilenameUtils.getName(diffFile.dstFileName), progressF.floatValue()); diffFile.dstFileContents = client.contents(file.links.patched_file.href); progressF.setValue(progressF.floatValue() + 1.0f / diffList.total_results); progress.progress("Completed loading contents", progressF.floatValue()); } } )); result.add(diffFile); } } for (Future future : futures) future.get(); return result; }