Info (non-fatal) warning when using #include?

Hi Stan people!

I am using the #include file.stan syntax but keep getting the message:

Info (non-fatal): Comments beginning with # are deprecated.  Please use // in place of # for line comments.

Is this necessary ? Can I stop it from spitting out the warning ?

Finlay

Make sure that there are no spaces before #include, it should not print out a warning.

Hi again, and thanks for replying mcol.

The behaviour is not quite as you describe:

  1. If I put no space, I get could not find include file: #include "../../../lib/functions.stan"
  2. If I put one space, it compiles, but presents the “Info (non-fatal)” warning.

The stanza in my .stan file is:

functions{
 #include "../../../lib/functions.stan"
}

If there is a space, it does not actually load the include.

I’m not sure how Stan finds the includes, but perhaps the problem is with the ../../../ part? I think the path must be relative to the Stan code that includes it, rather than the location where you run it from. In my code I have a chunk of code in the chunks subdirectory and the following works:

functions {
#include /chunk/fun.stan
}

Could you use absolute path?

Are you using PyStan, RStan, CmdStan, or something else? Each Stan interface has a different way to specify paths to search for #include'd files:

  • PyStan’s StanModel constructor takes an include_paths argument.
  • RStan, AFAIK, still uses the stanc_builder() to account for #includes.
  • CmdStan has the STANCFLAGS Makefile variable, which can be modified to include an --include_paths option, which takes a comma-separated list of directories as an argument.

Hi, I am using the RStan interface.

Still doesn’t work with the absolute path. I have tried:

#include /work/model/lib/functions.stan

and

#include "/work/model/lib/functions.stan"

Could it have something to do with the fact I am running inside a docker ?

F

There’s something peculiar about the way paths are interpreted, it frustrated me to no end when I first tried. My guess is that when you write /work/etc it gets interpreted as ./work/etc. At least this is what I think it’s happening since for me if I have the stan files in ./src/stan_files and I want to include ./src/stan_files/chunks/fun.stan my include is #include /chunks/fun.stan. I suggest you to try putting the files you want to include in a subdirectory and see if that takes you anywhere.