Exception: int variable contained non-int values

I’m using pystan and I get an error about integer type:

RuntimeError: Exception: int variable contained non-int values; processing stage=data initialization; variable name=cluster_allele_counts; base type=int  (in 'unknown file name' at line 8)

The variable cluster_allele_counts is a nested list of numbers:

cluster_allele_counts = [[[0,0] for c in range(max_cluster+1)] for x in range(total_loci)]

The only operation used to update the numbers is += 1 so they should all be integers.

Do I need to tell PyStan that the numbers are integers?

For example, is it better to convert the nested list to a numpy array and then set the type on the array explicitly?

I wish I could share a simple reproducible example, but I don’t have one. This is part of a bigger package with lots of steps.

Thanks for any help!

Can you share the declaration in the data block of the model this corresponds to?

Could cluster_allele_counts be an empty list in a certain case? That could trigger a known issue. (Not particularly well-documented here https://github.com/stan-dev/httpstan/issues/319)