Skip to content

Commit

Permalink
Add a few improvements from the removals PR
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Apr 3, 2023
1 parent 38f5702 commit d089a82
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 31 deletions.
6 changes: 2 additions & 4 deletions src/middle/Stan_math_signatures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ let distributions =
; ([Lpdf; Log], "inv_wishart", [DMatrix; DReal; DMatrix], SoA)
; ([Lpdf; Log], "lkj_corr", [DMatrix; DReal], AoS)
; ([Lpdf; Log], "lkj_corr_cholesky", [DMatrix; DReal], AoS)
; ([Lpdf; Log], "lkj_cov", [DMatrix; DVector; DVector; DReal], AoS)
; (full_lpdf_depr, "logistic", [DVReal; DVReal; DVReal], SoA)
; ([Lpdf; Rng; Cdf; Log], "loglogistic", [DVReal; DVReal; DVReal], SoA)
; (full_lpdf_depr, "lognormal", [DVReal; DVReal; DVReal], SoA)
Expand Down Expand Up @@ -1606,8 +1607,6 @@ let () =
add_unqualified
("lkj_corr_cholesky_rng", ReturnType UMatrix, [UInt; UReal], AoS) ;
add_unqualified ("lkj_corr_rng", ReturnType UMatrix, [UInt; UReal], AoS) ;
add_unqualified
("lkj_cov_log", ReturnType UReal, [UMatrix; UVector; UVector; UReal], AoS) ;
add_binary_vec_int_real "lmgamma" AoS ;
add_binary_vec "lmultiply" SoA ;
add_unqualified ("log", ReturnType UComplex, [UComplex], AoS) ;
Expand Down Expand Up @@ -2718,5 +2717,4 @@ let%expect_test "declarative distributions" =
|> print_endline ;
[%expect {|
binomial_coefficient_log
multiply_log
lkj_cov_log |}]
multiply_log |}]
4 changes: 4 additions & 0 deletions src/stancjs/stancjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ let stan2cpp model_name model_string is_flag_set flag_val =
flag_val "max-line-length"
|> Option.map ~f:int_of_string
|> Option.value ~default:78 in
let deprecation_warnings =
if canonicalizer_settings.deprecations then []
else Deprecation_analysis.collect_warnings typed_ast in
let warnings = warnings @ deprecation_warnings in
let mir = Ast_to_Mir.trans_prog model_name typed_ast in
let tx_mir = Transform_Mir.trans_prog mir in
if is_flag_set "auto-format" || is_flag_set "print-canonical" then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ data {
}
transformed data {
real transformed_data_real;
transformed_data_real = lkj_cov_log(d_matrix, d_vector, d_vector, d_real);
transformed_data_real = lkj_cov_log(d_matrix, d_vector, d_vector, d_int);
transformed_data_real = lkj_cov_lpdf(d_matrix | d_vector, d_vector, d_real);
transformed_data_real = lkj_cov_lpdf(d_matrix | d_vector, d_vector, d_int);
}
parameters {
matrix[d_int, d_int] p_matrix;
Expand All @@ -19,32 +19,31 @@ parameters {
}
transformed parameters {
real transformed_param_real;
transformed_param_real = lkj_cov_log(d_matrix, d_vector, d_vector, d_real);
transformed_param_real = lkj_cov_log(d_matrix, d_vector, d_vector, p_real);
transformed_param_real = lkj_cov_log(d_matrix, d_vector, p_vector, d_real);
transformed_param_real = lkj_cov_log(d_matrix, d_vector, p_vector, p_real);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, d_vector, d_real);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, d_vector, p_real);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, p_vector, d_real);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, p_vector, p_real);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, d_vector, d_real);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, d_vector, p_real);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, p_vector, d_real);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, p_vector, p_real);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, d_vector, d_real);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, d_vector, p_real);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, p_vector, d_real);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, p_vector, p_real);
transformed_param_real = lkj_cov_log(d_matrix, d_vector, d_vector, d_int);
transformed_param_real = lkj_cov_log(d_matrix, d_vector, p_vector, d_int);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, d_vector, d_int);
transformed_param_real = lkj_cov_log(d_matrix, p_vector, p_vector, d_int);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, d_vector, d_int);
transformed_param_real = lkj_cov_log(p_matrix, d_vector, p_vector, d_int);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, d_vector, d_int);
transformed_param_real = lkj_cov_log(p_matrix, p_vector, p_vector, d_int);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, d_vector, d_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, d_vector, p_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, p_vector, d_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, p_vector, p_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, d_vector, d_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, d_vector, p_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, p_vector, d_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, p_vector, p_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, d_vector, d_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, d_vector, p_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, p_vector, d_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, p_vector, p_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, d_vector, d_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, d_vector, p_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, p_vector, d_real);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, p_vector, p_real);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, d_vector, d_int);
transformed_param_real = lkj_cov_lpdf(d_matrix | d_vector, p_vector, d_int);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, d_vector, d_int);
transformed_param_real = lkj_cov_lpdf(d_matrix | p_vector, p_vector, d_int);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, d_vector, d_int);
transformed_param_real = lkj_cov_lpdf(p_matrix | d_vector, p_vector, d_int);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, d_vector, d_int);
transformed_param_real = lkj_cov_lpdf(p_matrix | p_vector, p_vector, d_int);
}
model {
y_p ~ normal(0, 1);
}

3 changes: 3 additions & 0 deletions test/integration/good/warning/pretty.expected
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,9 @@ Warning in 'lkj_cov_deprecation2.stan', line 8, column 2: increment_log_prob(...
is deprecated and will be removed in Stan 2.33.0. Use target += ...;
instead. This can be done automatically with the canonicalize flag for
stanc
Warning in 'lkj_cov_deprecation2.stan', line 8, column 21: lkj_cov_log is
deprecated and will be removed in Stan 2.33.0. Use lkj_cov_lpdf instead.
This can be automatically changed using the canonicalize flag for stanc
$ ../../../../../install/default/bin/stanc --auto-format lvalue_multiindex.stan
data {
array[5] matrix[5, 5] x;
Expand Down
1 change: 1 addition & 0 deletions test/integration/signatures/stan_math_distributions.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Display all Stan math distributions exposed in the language
inv_wishart: lpdf, log (deprecated)
lkj_corr: lpdf, log (deprecated)
lkj_corr_cholesky: lpdf, log (deprecated)
lkj_cov: lpdf, log (deprecated)
logistic: lpdf, rng, ccdf, cdf, log (deprecated)
loglogistic: lpdf, rng, cdf, log (deprecated)
lognormal: lpdf, rng, ccdf, cdf, log (deprecated)
Expand Down
1 change: 1 addition & 0 deletions test/integration/signatures/stan_math_signatures.t
Original file line number Diff line number Diff line change
Expand Up @@ -11518,6 +11518,7 @@ Display all Stan math signatures exposed in the language
lkj_corr_lpdf(matrix, real) => real
lkj_corr_rng(int, real) => matrix
lkj_cov_log(matrix, vector, vector, real) => real
lkj_cov_lpdf(matrix, vector, vector, real) => real
lmgamma(int, real) => real
lmgamma(int, vector) => vector
lmgamma(array[] int, vector) => vector
Expand Down

0 comments on commit d089a82

Please sign in to comment.