Skip to content

Commit a0bfcd8

Browse files
committed
Update deprecated syntax in tests
1 parent 0857b52 commit a0bfcd8

5 files changed

Lines changed: 27 additions & 34 deletions

File tree

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
data {
22
int<lower=0> N;
3-
int<lower=0,upper=1> y[N];
3+
array[N] int<lower=0, upper=1> y;
44
}
55
parameters {
6-
real<lower=0,upper=1> theta;
6+
real<lower=0, upper=1> theta;
77
}
88
model {
9-
theta ~ beta(1,1);
10-
for (n in 1:N)
9+
theta ~ beta(1, 1);
10+
for (n in 1 : N)
1111
y[n] ~ bernoulli(theta);
1212
}
13+
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
data {
22
int<lower=0> N;
3-
int<lower=0,upper=1> y[N];
3+
array[N] int<lower=0, upper=1> y;
44
}
55
parameters {
6-
real<lower=0,upper=1> theta;
6+
real<lower=0, upper=1> theta;
77
}
88
model {
9-
theta ~ beta(1,1);
10-
for (n in 1:N)
9+
theta ~ beta(1, 1);
10+
for (n in 1 : N)
1111
y[n] ~ bernoulli(theta);
1212
}
13+
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
data {
22
int<lower=0> N;
3-
int<lower=0,upper=1> y[N];
3+
array[N] int<lower=0, upper=1> y;
44
}
55
parameters {
6-
real<lower=0,upper=1> theta;
6+
real<lower=0, upper=1> theta;
77
}
88
model {
9-
theta ~ beta(1,1);
10-
for (n in 1:N)
9+
theta ~ beta(1, 1);
10+
for (n in 1 : N)
1111
y[n] ~ bernoulli(theta);
1212
}
13+

test/data/timeout.stan

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
data {
2-
// Indicator for endless looping.
3-
int loop;
2+
// Indicator for endless looping.
3+
int loop;
44
}
5-
65
transformed data {
7-
// Maybe loop forever so the model times out.
8-
real y = 1;
9-
while(loop && y) {
10-
y += 1;
11-
}
6+
// Maybe loop forever so the model times out.
7+
real y = 1;
8+
while (loop && (y != 0.0)) {
9+
y += 1;
10+
}
1211
}
13-
1412
parameters {
15-
real x;
13+
real x;
1614
}
17-
1815
model {
19-
// A nice model so we can get a fit for the `generated_quantities` call.
20-
x ~ normal(0, 1);
16+
// A nice model so we can get a fit for the `generated_quantities` call.
17+
x ~ normal(0, 1);
2118
}
19+

test/test_model.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,11 @@ def test_model_format_deprecations() -> None:
514514

515515
sys_stdout = io.StringIO()
516516
with contextlib.redirect_stdout(sys_stdout):
517-
model.format()
517+
model.format(canonicalize=True)
518518

519519
formatted = sys_stdout.getvalue()
520520
assert "//" in formatted
521521
assert "#" not in formatted
522-
assert formatted.count('(') == 5
523-
524-
sys_stdout = io.StringIO()
525-
with contextlib.redirect_stdout(sys_stdout):
526-
model.format(canonicalize=True)
527-
528-
formatted = sys_stdout.getvalue()
529-
print(formatted)
530522
assert "<-" not in formatted
531523
assert formatted.count('(') == 0
532524

0 commit comments

Comments
 (0)