# 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

**URL:** <https://discourse.pymc.io/t/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/10542>\
**Category:** v5\
**Tags:** bug\
**Created:** [October 6, 2022, 8:58am UTC](https://discourse.pymc.io/t/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/10542 "2022-10-06T08:58:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oliver/32/3849_2.png) [@Oliver](https://discourse.pymc.io/u/Oliver)\
**Post date:** [October 6, 2022, 8:58am UTC](https://discourse.pymc.io/t/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/10542/1 "2022-10-06T08:58:56Z")

</div>

I followed [this example](https://www.pymc.io/projects/examples/en/latest/gaussian_processes/GP-Heteroskedastic.html) with my own data (2 input, 1 continuous output), using v4.1.4 and sampled the trace with jax.

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

```

returns

```auto
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 )

```

---

<div class="post-metadata">

**Author:** ![Oliver](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oliver/32/3849_2.png) [@Oliver](https://discourse.pymc.io/u/Oliver)\
**Post date:** [October 6, 2022, 9:03am UTC](https://discourse.pymc.io/t/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/10542/2 "2022-10-06T09:03:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![falk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/falk/32/4421_2.png) [@falk](https://discourse.pymc.io/u/falk)\
**Post date:** [October 6, 2022, 10:02am UTC](https://discourse.pymc.io/t/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/10542/3 "2022-10-06T10:02:53Z")

</div>

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.

> [@Value error in chains for a gaussian process](https://discourse.pymc.io/t/value-error-in-chains-for-a-gaussian-process/9894/4):
>
> If I can add to the conversation, do not use the samples argument in v4. The plan is to remove it, see [Remove `samples` and `keep_size` from posterior\_predictive · Issue #5775 · pymc-devs/pymc · GitHub](https://github.com/pymc-devs/pymc/issues/5775). If you want to generate posterior predictive samples for a subset of the posterior only, you should provide a sliced posterior to sample\_posterior\_predictive as shown in the api docs example (bottom of the page): [pymc.sample\_posterior\_predictive — PyMC 4.1.2 documentation](https://www.pymc.io/projects/docs/en/stable/api/generated/pymc.sample_posterior_predictive.html)

---

<div class="post-metadata">

**Author:** ![OriolAbril](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oriolabril/32/2497_2.png) [@OriolAbril](https://discourse.pymc.io/u/OriolAbril)\
**Post date:** [October 11, 2022, 10:43am UTC](https://discourse.pymc.io/t/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/10542/4 "2022-10-11T10:43:11Z")

</div>

> [@Oliver](#):
>
> I think the example in the tutorial should be updated.

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](https://github.com/pymc-devs/pymc-examples/issues/169) that you can see is 1) open and 2) in the “To Do” column (leftmost one in the [project tracker](https://github.com/pymc-devs/pymc-examples/projects/1#card-62770841)). Any help updating this or other notebooks is much appreciated.
