Print debugging from within functions

Hi Stan team -

It seems like print() statements don’t work inside functions. At least this is my experience with cmdstanR and the latest cmdstan.

This is somewhat of a problem with the way that reduce_sum works, packing everything into a function. Without being able to debug, it gets tricky to figure out what’s going on inside that function.

Any ideas/recommendations/eye rolls?


1 Like

This model works for me with cmdstan 2.24 on the command line and in the Github cmdstanr:

functions {
  real foo(real a) {
    return a;

parameters {
  real a;

model {
  foo(a) ~ normal(0, 1);

Can you try this out?

1 Like

@saudiwin there is a known bug that prints do not show for transformed data in cmdstanr

It still shows up if you do fit$output(id) but that is obviously less helpful.

If it does not work anywhere else, we would very much like to know more. Thanks!

1 Like

If it’s in reduce_sum, would disabling threading help?

1 Like