From 0ab6f214945e5ecdc8d80a70790797068af82da4 Mon Sep 17 00:00:00 2001 From: Lars-B Date: Mon, 5 May 2025 11:44:11 -0700 Subject: [PATCH] Adding getter and setter for m_ranges christiaanjs/beast-validation#2 --- src/beastfx/app/tools/LogAnalyser.java | 53 ++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/beastfx/app/tools/LogAnalyser.java b/src/beastfx/app/tools/LogAnalyser.java index 96bb532..d12f113 100644 --- a/src/beastfx/app/tools/LogAnalyser.java +++ b/src/beastfx/app/tools/LogAnalyser.java @@ -46,6 +46,11 @@ protected enum type { */ protected List[] m_ranges; + public List[] getRanges() {return m_ranges;} + + public void setRanges(List[] ranges) {this.m_ranges = ranges;} + + /** * data from log file with burn-in removed * */ @@ -152,7 +157,7 @@ public LogAnalyser() { * * @param args * @param burnInPercentage burnInPercentage typical = 10; percentage of data that can be ignored - * @throws IOException + * @throws IOException */ public LogAnalyser(String[] args, int burnInPercentage) throws IOException { this(args, burnInPercentage, false, true); @@ -178,11 +183,11 @@ public LogAnalyser(String fileName, int burnInPercentage) throws IOException { public LogAnalyser(String fileName, int burnInPercentage, String [] tags) throws IOException { this(fileName, burnInPercentage, false, true, tags); } - + public LogAnalyser(String fileName, int burnInPercentage, boolean quiet) throws IOException { this(fileName, burnInPercentage, quiet, true, null); } - + public LogAnalyser(String fileName, int burnInPercentage, boolean quiet, String [] tags) throws IOException { this(fileName, burnInPercentage, quiet, true, tags); } @@ -194,7 +199,7 @@ public LogAnalyser(String fileName) throws IOException { public LogAnalyser(String fileName, int burnInPercentage, boolean quiet, boolean calcStats) throws IOException { this(fileName, burnInPercentage, quiet, calcStats, null); } - + public LogAnalyser(String fileName, int burnInPercentage, boolean quiet, boolean calcStats, String [] tags) throws IOException { this.fileName = fileName; this.quiet = quiet; @@ -238,7 +243,7 @@ protected void readLogFile(String fileName, int burnInPercentage) throws IOExcep // grab data from the log, ignoring burn in samples m_types = new type[items]; Arrays.fill(m_types, type.INTEGER); - int reported = 0; + int reported = 0; while (fin.ready()) { str = fin.readLine(); int i = 0; @@ -275,7 +280,7 @@ protected void readLogFile(String fileName, int burnInPercentage) throws IOExcep m_types[i] = type.BOOL; else m_types[i] = type.NOMINAL; - + fin.close(); } // readLogFile @@ -286,7 +291,7 @@ protected void readLogFile(String fileName, int burnInPercentage) throws IOExcep public void calcStats() { calcStats(null); } - + public void calcStats(String [] tags) { logln("\nCalculating statistics\n\n" + BAR); int stars = 0; @@ -317,7 +322,7 @@ public void calcStats(String [] tags) { m_fMean[i] = Double.NaN; m_fStdDev[i] = Double.NaN; } - + if (m_types[i] == type.REAL || m_types[i] == type.INTEGER) { // calc median, and 95% HPD interval Double[] sorted = trace.clone(); @@ -336,12 +341,12 @@ public void calcStats(String [] tags) { } m_f95HPDlow[i] = sorted[hpdIndex]; m_f95HPDup[i] = sorted[hpdIndex + n]; - + // calc effective sample size m_fACT[i] = ESS.ACT(m_fTraces[i], sampleInterval); m_fStdError[i] = ESS.stdErrorOfMean(trace, sampleInterval); m_fESS[i] = trace.length / (m_fACT[i] / sampleInterval); - + // calc geometric mean if (sorted[0] > 0) { // geometric mean is only defined when all elements are positive @@ -530,7 +535,7 @@ public String getLogFile() { public void print(PrintStream out) { print(out, null); } - + public void print(PrintStream out, String [] tags) { // set up header for prefix, if any is specified String prefix = System.getProperty("prefix"); @@ -544,7 +549,7 @@ public void print(PrintStream out, String [] tags) { } } } - + try { // delay so that stars can be flushed from stderr Thread.sleep(100); @@ -598,7 +603,7 @@ public void printOneLineHeader(PrintStream out, String [] tags) { out.println("\t"); } - + private boolean matchesTags(String [] tags, int paramIdx) { if (tags == null) { return true; @@ -611,7 +616,7 @@ private boolean matchesTags(String [] tags, int paramIdx) { } return false; } - + /** * Display results for single log on one line. * @@ -620,7 +625,7 @@ private boolean matchesTags(String [] tags, int paramIdx) { public void printOneLine(PrintStream out) { printOneLine(out, null); } - + public void printOneLine(PrintStream out, String [] tags) { for (int paramIdx=1; paramIdx files; int burnInPercentage; String [] tags; - + CoreRunnable(int start, int end, List files, CountDownLatch countDown, int burnInPercentage, String [] tags) { this.start = start; this.end = end; @@ -698,12 +703,12 @@ public void run() { while (!headerPrinted) { Thread.sleep(500); } - + synchronized (countDown) { System.out.print(lineNr + "\t" + files.get(i) + "\t"); lineNr++; analyser.printOneLine(System.out, tags); - } + } } catch (IOException | InterruptedException e) { e.printStackTrace(); } @@ -713,7 +718,7 @@ public void run() { } // CoreRunnable - + /** * @param args */ @@ -808,19 +813,19 @@ public static void main(String[] args) { } countDown.await(); - + // gracefully exit exec.shutdownNow(); System.exit(0); - + } else { for (int idx=0; idx