Skip to content

Commit

Permalink
pretty rough fix for an off-by-one
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Apr 10, 2024
1 parent 4abcb32 commit a5f8f0f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/org/rascalmpl/interpreter/DefaultTestResultListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public void done() {
if (ignored != 0) {
out.println("\t" + ignored + "/" + count + " tests ignored");
}

out.flush();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ bool leq(num a, num b) = a < b ? true : eq(a,b);
test bool geometricLessThanArithmeticMean(list[num] nums) {
if (nums == []) return true;
nums = abs(nums);
println(nums);
nums = assureRange(nums, 0.1, 30);
return leq(geometricMean(nums), mean(nums));
}
Expand All @@ -41,7 +40,6 @@ test bool percentileRelation(list[num] nums, int a, int b) {
test bool varianceIsPositive(list[num] nums) {
if (nums == []) return true;
println("varianceIsPositive: <nums>");
nums = assureRange(nums, 0.0001, 400);
return variance(nums) >= 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module lang::rascal::tests::library::analysis::statistics::RangeUtils

import util::Math;
import IO;

@synopsis{list of absolute numbers for every list element.}
list[&T <: num] abs(list[&T <: num] nums) = [abs(n) | n <- nums];
Expand All @@ -20,12 +21,12 @@ best if `y - x >= high - low`, otherwise parts of the target range may be unreac
window = high - low;

// jump above the lower bound into the range with steps sized `window`
if (target < low) {
while (target < low) {
target += ceil(low / window - target / window) * window;
}

// or jump below the high bound into the range with steps sized `window`
if (high < target) {
while (high < target) {
target -= ceil(target / window - high / window) * window;
}

Expand Down

0 comments on commit a5f8f0f

Please sign in to comment.