stan-dev / pystan2

PyStan, the Python interface to Stan
GNU General Public License v3.0
921 stars 191 forks source link

Unhelpful TypeError exception in sampling #717

Closed groceryheist closed 4 years ago

groceryheist commented 4 years ago

Summary:

I try to fit a model and get ignored TypeError exceptions and messages from "._set_stanargs_from_dict. The error message doesn't tell me where the problem is.

Description:

I'm not sure if the bug is that this error happens at all or if it's just an unhelpful error message.

Reproducible Steps:

I discovered the issue trying to fit the attached model (heaps_poisson_seasonality.stan) with pystan 0.19.1.1 The model was working fine until I went to add conditional operators on line 95 so the stan program can work even if no seasonality data is passed in. I'll also provide data (data.pickle) and a python script for fitting the model (test.py).

The files are in reproduce.zip reproduce.zip

Current Output:

TypeError: an integer is required
Exception ignored in: 'stanfit4heaps_poisson_seasonality_67eb88e318d6ffbb733000448e59f687_9047264962651855902._set_stanargs_from_dict'
TypeError: an integer is required
TypeError: an integer is required
Exception ignored in: 'stanfit4heaps_poisson_seasonality_67eb88e318d6ffbb733000448e59f687_9047264962651855902._set_stanargs_from_dict'
TypeError: an integer is required
TypeError: an integer is required
Exception ignored in: 'stanfit4heaps_poisson_seasonality_67eb88e318d6ffbb733000448e59f687_9047264962651855902._set_stanargs_from_dict'
TypeError: an integer is required
TypeError: an integer is required
Exception ignored in: 'stanfit4heaps_poisson_seasonality_67eb88e318d6ffbb733000448e59f687_9047264962651855902._set_stanargs_from_dict'
TypeError: an integer is required

Expected Output:

I'd like the model to fit or an error message telling me what is wrong.

PyStan Version:

2.19.1.1

Python Version:

3.7.7

Operating System:

CentOS 7

groceryheist commented 4 years ago

Update: I found that the problem comes from passing strings as arguments.