Skip to content

Commit

Permalink
Jacobian message uses target +=, fixes #2066
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Carpenter committed Oct 25, 2016
1 parent 946a711 commit 2aa4e85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/stan/lang/grammars/semantic_actions_def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,16 +1066,15 @@ namespace stan {
pass = false;
return;
}

// test for LHS not being purely a variable
if (has_non_param_var(s.expr_, var_map)) {
error_msgs << "Warning (non-fatal):"
<< std::endl
<< "Left-hand side of sampling statement (~) may contain a"
<< " non-linear transform of a parameter or local variable."
<< std::endl
<< "If so, you need to call increment_log_prob() with"
<< " the log absolute determinant of the Jacobian of"
<< "If it does, you need to include a target += statement"
<< " with the log absolute determinant of the Jacobian of"
<< " the transform."
<< std::endl
<< "Left-hand-side of sampling statement:"
Expand Down
18 changes: 12 additions & 6 deletions src/test/unit/lang/parser/statement_grammar_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,23 @@ TEST(langParserStatementGrammar, deprecateIncrementLogProb) {
TEST(langParserStatementGrammarDef, jacobianAdjustmentWarning) {
test_parsable("validate_jacobian_warning_good");
test_warning("validate_jacobian_warning1",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
test_warning("validate_jacobian_warning2",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
test_warning("validate_jacobian_warning3",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
test_warning("validate_jacobian_warning4",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
test_warning("validate_jacobian_warning5",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
test_warning("validate_jacobian_warning6",
"If so, you need to call increment_log_prob() with the log");
"you need to include a target += statement with"
" the log absolute determinant of the Jacobian of the transform.");
}

TEST(langParserStatementGrammarDef, jacobianUserFacing) {
Expand Down

0 comments on commit 2aa4e85

Please sign in to comment.