minor fix for sampling window test stability

This commit is contained in:
Jonathan Shook 2023-11-01 11:24:45 -05:00
parent b50cb7f87a
commit a1445927b9

View File

@ -58,7 +58,7 @@ public final class FrameSample {
if (active) { if (active) {
this.endAt = endTime; this.endAt = endTime;
this.endval = (criterion().evaltype() != EvalType.remix) ? criterion().supplier().getAsDouble() : Double.NaN; this.endval = (criterion().evaltype() != EvalType.remix) ? criterion().supplier().getAsDouble() : Double.NaN;
calculateBasis(); calculateBasis(endTime);
this.active = false; this.active = false;
} else { } else {
throw new RuntimeException("Can't stop an inactive frame."); throw new RuntimeException("Can't stop an inactive frame.");
@ -67,10 +67,14 @@ public final class FrameSample {
} }
private void calculateBasis() { private void calculateBasis() {
calculateBasis(System.currentTimeMillis());
}
private void calculateBasis(long now) {
if (!active) { if (!active) {
throw new RuntimeException("Calculations on inactive windows should not be done."); throw new RuntimeException("Calculations on inactive windows should not be done.");
} }
this.endAt = System.currentTimeMillis(); this.endAt = now;
this.endval = (criterion().evaltype() != EvalType.remix) ? criterion().supplier().getAsDouble() : Double.NaN; this.endval = (criterion().evaltype() != EvalType.remix) ? criterion().supplier().getAsDouble() : Double.NaN;
double seconds = deltaT(); double seconds = deltaT();
double basis = switch (criterion.evaltype()) { double basis = switch (criterion.evaltype()) {