Skip to content

Commit

Permalink
test: Transform Stan code to follow array syntax.
Browse files Browse the repository at this point in the history
Added changes to Stan code in tests to follow array syntax.
  • Loading branch information
ahartikainen authored and riddell-stan committed Sep 11, 2023
1 parent f9b3e44 commit d00aa36
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/test_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
program_code = """
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
array[N] int<lower=0,upper=1> y;
}
parameters {
real<lower=0,upper=1> theta;
Expand Down
30 changes: 15 additions & 15 deletions tests/test_cvodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
# from integrate_ode_bdf.stan
program_code = """
functions {
real[] sho(real t,
real[] y,
real[] theta,
real[] x,
int[] x_int) {
real dydt[2];
array[] real sho(real t,
array[] real y,
array[] real theta,
array[] real x,
array[] int x_int) {
array[2] real dydt;
dydt[1] = y[2];
dydt[2] = -y[1] - theta[1] * y[2];
return dydt;
}
}
data {
int<lower=1> T;
real y0_d[2];
array[2] real y0_d;
real t0;
real ts[T];
real theta_d[1];
real x[0];
int x_int[0];
array[T] real ts;
array[1] real theta_d;
array[0] real x;
array[0] int x_int;
}
parameters {
real y0_p[2];
real theta_p[1];
array[2] real y0_p;
array[1] real theta_p;
}
model {
real y_hat[T,2];
array[T,2] real y_hat;
y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int);
Expand All @@ -42,7 +42,7 @@
y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
}
generated quantities {
real y_hat[T,2];
array[T,2] real y_hat;
y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_bdf(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_bdf(sho, y0_p, t0, ts, theta_d, x, x_int);
Expand Down
8 changes: 4 additions & 4 deletions tests/test_eight_schools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
program_code = """
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
array[J] real y; // estimated treatment effects
array[J] real<lower=0> sigma; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
array[J] real eta;
}
transformed parameters {
real theta[J];
array[J] real theta;
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fixed_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
program_code = """
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
array[N] int<lower=0,upper=1> y;
}
parameters {
real<lower=0,upper=1> theta;
Expand Down
8 changes: 4 additions & 4 deletions tests/test_large_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
program_code = """
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
array[J] real y; // estimated treatment effects
array[J] real<lower=0> sigma; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
array[J] real eta;
}
transformed parameters {
real theta[J];
array[J] real theta;
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
Expand Down

0 comments on commit d00aa36

Please sign in to comment.