alashworth / test-issue-import

0 stars 0 forks source link

warnings for unused parameters in I/O #133

Open alashworth opened 5 years ago

alashworth commented 5 years ago

Issue by bob-carpenter Sunday Mar 05, 2017 at 16:15 GMT Originally opened as https://github.com/stan-dev/stan/issues/2239


Summary:

Add a warning for data variables included in a data file that are not used in the model.

Current Version:

v2.14.0

alashworth commented 5 years ago

Comment by doikov Wednesday Apr 26, 2017 at 01:22 GMT


Do we need to check that the variable is really used in the model, I mean in a strict sense: changing the value of variable leads to changing of the output?

I suppose not, because it sounds too unrealistic to detect that, am I right?

So, If we only need to detect that the model class somehow touch the variable, then the problem looks not so difficult: we can

  1. store an additional flag for every variable name in var_context,
  2. fill this flag on every call _var_context.valsr(name) or _var_context.valsi(name) for particular variable name,
  3. print the warning if some flag is not filled. (Check it in the desctructor of var_context, possibly).
alashworth commented 5 years ago

Comment by bob-carpenter Wednesday Apr 26, 2017 at 17:20 GMT


@doykov --- you're right that it's impossible to check if a variable is really used.

What we want to flag is any variable with a definition in the input file (and in the interfaces in the dictionary, list whatever) is declared as a data variable in the program.

What you're suggesting is the only way I can see to implement it.

This isn't such a high priority issue as we plan to swap out the R dump format in the near future for either JSON or protocol buffers. And most of our users use R or Python anyway. But if you want to tackle it, it'll be useful for at least another year or two!

alashworth commented 5 years ago

Comment by sakrejda Friday Apr 28, 2017 at 14:13 GMT


@bob-carpenter I suggested this issue because @doykov did a GSoC proposal for the protobuf project and part of that is working with var contexts. I agree this isn't a very high priority issue but it's a good excuse for him to muck around in the var_context code.