Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pystan does not accept length-zero data vectors #306

Closed
adaly opened this issue May 25, 2021 · 3 comments
Closed

Pystan does not accept length-zero data vectors #306

adaly opened this issue May 25, 2021 · 3 comments

Comments

@adaly
Copy link

adaly commented May 25, 2021

After upgrading to pystan 3, I noticed that I am no longer able to run a number of older models containing vectors in the data block that may be length 0. For instance, in older versions of pystan (2.19.0.0), I might declare a model with a data block containing the following variables:

data {
    int<lower=0, upper=1> nb;
    int<lower=1> alpha[nb];
    ...
}
...

And then pass the following entries in a data dict in order to fit the model:

import numpy as np

data_dict = {
    'nb': 0,
    'alpha': np.array([], dtype=int),
    ...
}

As of upgrading to Pystan 3.1.1, attempting to do so yields the following error:

RuntimeError: Error calling get_param_names: `Exception: int variable contained non-int values; processing stage=data initialization; variable name=alpha; base type=int (in '/var/folders/cz/tz9nr4710px51vhl4kq588jr0001bz/T/httpstan_g7gn5td2/model_4zofs5uu.stan', line 8, column 4 to column 27)`

Perhaps this is still possible through some other means, but I cannot find anything in the pystan 3 documentation about how to provide zero-length vectors as inputs.

I am working on Mac OS Catalina (10.15.7) with Python 3.7.9 and pystan 3.1.1.

@adaly adaly added the bug label May 25, 2021
@riddell-stan riddell-stan changed the title Pystan 3.1.1 no longer accepts length-zero input vectors Pystan does not accept length-zero data vectors May 25, 2021
@riddell-stan
Copy link
Contributor

Thanks. This is a known issue. But it's one we haven't been tracking as clearly as we should.

To solve this problem, httpstan needs to get input type information from stanc3 somehow. There may be an open issue or two which can be linked to this.

@riddell-stan riddell-stan pinned this issue May 25, 2021
@stale
Copy link

stale bot commented Aug 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 24, 2021
@stale
Copy link

stale bot commented Nov 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 25, 2021
@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants