What does this error mean? IncorrectArgumentsError: Should not specify both keep_size and samples arguments. See the docstring of the samples argument for more details

I followed this example with my own data (2 input, 1 continuous output), using v4.1.4 and sampled the trace with jax.

with model:
    ppc = pm.sample_posterior_predictive(trace, samples=100, var_names=["fnew"])

returns

IncorrectArgumentsError                   Traceback (most recent call last)
<ipython-input-20-7da9f5d1c2b9> in <module>
      3 
      4 with model:
----> 5     ppc = pm.sample_posterior_predictive(trace, samples=100, var_names=["fnew"])

/usr/local/lib/python3.7/dist-packages/pymc/sampling.py in sample_posterior_predictive(trace, samples, model, var_names, keep_size, random_seed, progressbar, return_inferencedata, extend_inferencedata, predictions, idata_kwargs, compile_kwargs)
   1857     if keep_size and samples is not None:
   1858         raise IncorrectArgumentsError(
-> 1859             "Should not specify both keep_size and samples arguments. "
   1860             "See the docstring of the samples argument for more details."
   1861         )

ok. I figured it out looking at the source code.
The keep_size argument by default == True, so setting it to False works. I think the example in the tutorial should be updated.

Yes, this seems to be a common problem (I am just now struggling with a similar issue).

Note that the intention is to remove both keywords, cf.

1 Like

Indeed, the example in the gallery needs to be updated. As you can see at the bottom of the notebook it runs on pymc3 3.11.2. We have this tracker issue: GP Heteroskedastic · Issue #169 · pymc-devs/pymc-examples · GitHub that you can see is 1) open and 2) in the “To Do” column (leftmost one in the project tracker). Any help updating this or other notebooks is much appreciated.