Skip to content

Commit

Permalink
Replace deprecated body with do
Browse files Browse the repository at this point in the history
  • Loading branch information
nordlow authored and John-Colvin committed Aug 31, 2021
1 parent ca0fb54 commit 3745079
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 34 deletions.
20 changes: 10 additions & 10 deletions source/dstats/alloc.d
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public:
void popFront()
in {
assert(!empty);
} body {
} do {
this._length--;
if(next is null) {
do {
Expand Down Expand Up @@ -149,14 +149,14 @@ public:
@property ref Unqual!(K) front()
in {
assert(!empty);
} body {
} do {
return *frontElem;
}
} else {
@property Unqual!(K) front()
in {
assert(!empty);
} body {
} do {
return *frontElem;
}
}
Expand Down Expand Up @@ -911,7 +911,7 @@ struct AVLNodeBitwise(T) {
void left(typeof(this)* newLeft) nothrow @property
in {
assert((cast(size_t) newLeft & mask) == 0);
} body {
} do {
_left &= mask;
_left |= cast(size_t) newLeft;
assert(left is newLeft);
Expand All @@ -928,7 +928,7 @@ struct AVLNodeBitwise(T) {
void right(typeof(this)* newRight) nothrow @property
in {
assert((cast(size_t) newRight & mask) == 0);
} body {
} do {
_right &= mask;
_right |= cast(size_t) newRight;
assert(right is newRight);
Expand Down Expand Up @@ -1054,7 +1054,7 @@ private:
assert(node.left !is null);
assert( abs(node.balance) <= 2);

} body {
} do {
Node* newHead = node.left;
node.left = newHead.right;
newHead.right = node;
Expand All @@ -1070,7 +1070,7 @@ private:
in {
assert(node.right !is null);
assert( abs(node.balance) <= 2);
} body {
} do {
Node* newHead = node.right;
node.right = newHead.left;
newHead.left = node;
Expand All @@ -1087,7 +1087,7 @@ private:
assert(node is null || abs(node.balance) <= 2);
} out(ret) {
assert( abs(ret.balance) < 2);
} body {
} do {
if(node is null) {
return null;
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ private:
in {
assert(freeList);
assert(*freeList);
} body {
} do {
auto ret = *freeList;
*freeList = ret.right;
return ret;
Expand All @@ -1153,7 +1153,7 @@ private:
Node* newNode(T payload)
in {
assert(freeList, "Uninitialized StackTree!(" ~ T.stringof ~ ")");
} body {
} do {
Node* ret;
if(*freeList !is null) {
ret = popFreeList();
Expand Down
6 changes: 3 additions & 3 deletions source/dstats/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ private void averageTies(T, U)(T sortedInput, U[] ranks, size_t[] perms)
in {
assert(sortedInput.length == ranks.length);
assert(ranks.length == perms.length);
} body {
} do {
size_t tieCount = 1;
foreach(i; 1..ranks.length) {
if(sortedInput[i] == sortedInput[i - 1]) {
Expand Down Expand Up @@ -856,7 +856,7 @@ unittest {
double logNcomb(ulong n, ulong k)
in {
assert(k <= n);
} body {
} do {
if(n < k) return -double.infinity;
//Extra parentheses increase numerical accuracy.
return logFactorial(n) - (logFactorial(k) + logFactorial(n - k));
Expand Down Expand Up @@ -1220,7 +1220,7 @@ public:
this(uint n, uint r)
in {
assert(n >= r);
} body {
} do {
if(r > 0) {
pos = (seq(0U, r)).ptr;
pos[r - 1]--;
Expand Down
6 changes: 3 additions & 3 deletions source/dstats/cor.d
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ package KendallLowLevel kendallCorDestructiveLowLevelImpl
(R1, R2)(R1 input1, R2 input2, bool needTies)
in {
assert(input1.length == input2.length);
} body {
} do {
static ulong getMs(V)(V data) { //Assumes data is sorted.
ulong Ms = 0, tieCount = 0;
foreach(i; 1..data.length) {
Expand Down Expand Up @@ -707,7 +707,7 @@ in {
// implementation exists in this module for large N, but when N gets this
// large it's not even correct due to overflow errors.
assert(input1.length < 1 << 15);
} body {
} do {
int m1 = 0, m2 = 0;
int s = 0;

Expand Down Expand Up @@ -1259,7 +1259,7 @@ private void dotMatrix(Matrix)(
}

assert(ret.rows == rows.length);
} body {
} do {
// HACK: Before the multithreaded portion of this algorithm
// starts, make sure that there's no need to unshare ret if it's
// using ref-counted COW semantics.
Expand Down
10 changes: 5 additions & 5 deletions source/dstats/distrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ enum POISSON_NORMAL = 1UL << 12; // Where to switch to normal approx.
private double normApproxPoisCDF(ulong k, double lambda)
in {
assert(lambda > 0);
} body {
} do {
double sd = sqrt(lambda);
// mean == lambda.
return normalCDF(k + 0.5L, lambda, sd);
Expand Down Expand Up @@ -278,7 +278,7 @@ unittest {
private double normApproxPoisCDFR(ulong k, double lambda)
in {
assert(lambda > 0);
} body {
} do {
double sd = sqrt(lambda);
// mean == lambda.
return normalCDFR(k - 0.5L, lambda, sd);
Expand Down Expand Up @@ -403,7 +403,7 @@ private double normApproxBinomCDF(double k, double n, double p)
in {
assert(k <= n);
assert(p >= 0 && p <= 1);
} body {
} do {
double mu = p * n;
double sd = sqrt( to!double(n) ) * sqrt(p) * sqrt(1 - p);
double xCC = k + 0.5L;
Expand Down Expand Up @@ -482,7 +482,7 @@ private double normApproxBinomCDFR(ulong k, ulong n, double p)
in {
assert(k <= n);
assert(p >= 0 && p <= 1);
} body {
} do {
double mu = p * n;
double sd = sqrt( to!double(n) ) * sqrt(p) * sqrt(1 - p);
double xCC = k - 0.5L;
Expand Down Expand Up @@ -622,7 +622,7 @@ unittest {
double hypergeometricPMF(long x, long n1, long n2, long n)
in {
assert(x <= n);
} body {
} do {
if(x > n1 || x < (n - n2)) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions source/dstats/regress.d
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ private void shermanMorrisonRidge(
assert(lambda > 0);
foreach(col; x) assert(col.length == x[0].length);
if(x.length) assert(y.length == x[0].length);
} body {
} do {
auto alloc = newRegionAllocator();
immutable p = x.length;
if(p == 0) return;
Expand Down Expand Up @@ -2800,7 +2800,7 @@ private double threeDot(
) in {
assert(x1.length == x2.length);
assert(x2.length == x3.length);
} body {
} do {
immutable n = x1.length;
auto avec = x1.ptr, bvec = x2.ptr, cvec = x3.ptr;
typeof(return) sum0 = 0, sum1 = 0;
Expand Down
15 changes: 7 additions & 8 deletions source/dstats/sort.d
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ in {
foreach(array; data[1..$]) {
assert(array.length == len);
}
} body {
} do {
if(data[0].length < 25) {
// Skip computing logarithm rather than waiting until qsortImpl to
// do this.
Expand Down Expand Up @@ -481,7 +481,7 @@ in {
static if(!is(typeof(array) == ulong*))
assert(array.length == len);
}
} body {
} do {
if(data[0].length < 65) { //Avoid mem allocation.
return insertionSortImpl!(compFun)(data);
}
Expand Down Expand Up @@ -602,7 +602,7 @@ in {
static if(!is(typeof(array) == ulong*))
assert(array.length == len);
}
} body {
} do {
static if(is(T[$ - 1] == ulong*)) {
enum dl = data.length - 1;
} else {
Expand Down Expand Up @@ -737,7 +737,7 @@ in {
foreach(array; data[1..$]) {
assert(array.length == len);
}
} body {
} do {
auto toSort = prepareForSorting!compFun(data[0]);
mergeSortInPlaceImpl!compFun(toSort, data[1..$]);
postProcess!compFun(data[0]);
Expand Down Expand Up @@ -854,7 +854,7 @@ in {
foreach(array; data[1..$]) {
assert(array.length == len);
}
} body {
} do {
auto toSort = prepareForSorting!compFun(data[0]);
heapSortImpl!compFun(toSort, data[1..$]);
postProcess!compFun(data[0]);
Expand Down Expand Up @@ -944,7 +944,7 @@ in {
static if(!is(typeof(array) == ulong*))
assert(array.length == len);
}
} body {
} do {
auto toSort = prepareForSorting!compFun(data[0]);
insertionSortImpl!compFun(toSort, data[1..$]);
postProcess!compFun(data[0]);
Expand Down Expand Up @@ -1111,7 +1111,7 @@ in {
foreach(array; data[1..$]) {
assert(array.length == len);
}
} body {
} do {
// Don't use the float-to-int trick because it's actually slower here
// because the main part of the algorithm is O(N), not O(N log N).
return partitionKImpl!compFun(data, k);
Expand Down Expand Up @@ -1293,4 +1293,3 @@ unittest {
assert(more.getSorted == qsort!("a > b")(nums[0..5]));
}
}

6 changes: 3 additions & 3 deletions source/dstats/tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ private double wilcoxonSignedRankPval(double W, ulong N, Alt alt = Alt.twoSided,
in {
assert(N > 0);
assert(tieSum >= 0 || isNaN(tieSum));
} body {
} do {
if(alt == Alt.none) {
return double.nan;
}
Expand Down Expand Up @@ -3146,15 +3146,15 @@ private double ksPval(ulong N, ulong Nprime, double D)
in {
assert(D >= -1);
assert(D <= 1);
} body {
} do {
return 1 - kolmogorovDistrib(sqrt(cast(double) (N * Nprime) / (N + Nprime)) * abs(D));
}

private double ksPval(ulong N, double D)
in {
assert(D >= -1);
assert(D <= 1);
} body {
} do {
return 1 - kolmogorovDistrib(abs(D) * sqrt(cast(double) N));
}

Expand Down

0 comments on commit 3745079

Please sign in to comment.