PyStan: TypeError in extract()

24 views
Skip to first unread message

Stephen Feeney

unread,
Feb 17, 2017, 12:26:04 PM2/17/17
to Stan users mailing list
Hi all

Firstly, thanks to the Stan devs for writing such an awesome piece of software! Secondly, hopefully this isn't a duplicate of any posts: I've searched around and haven't found anything that matches.

Anyway, I upgraded to the latest version of PyStan this morning (pystan.__version__ = '2.14.0.0') and I'm now having trouble extracting fits. Regardless of the arguments I pass to the extract() call, I get the following error:

Traceback (most recent call last):
  File "stan_cpl.py", line 495, in <module>
    samples = fit.extract()
  File "stanfit4anon_model_86f0c8d2f63dcf12b6bc584c29bf7ac4_1190911492343917902.pyx", line 574, in stanfit4anon_model_86f0c8d2f63dcf12b6bc584c29bf7ac4_1190911492343917902.StanFit4Model.extract (/var/folders/4q/2gmnqtb5211g95b5p6rlh32800011w/T/tmpzoG1H_/stanfit4anon_model_86f0c8d2f63dcf12b6bc584c29bf7ac4_1190911492343917902.cpp:11624)
TypeError: 'float' object cannot be interpreted as an index

This was working with version 2.12.0.0 this morning, and nothing else has changed about the way I'm sampling my model: sampling still completes as normal, and I can print the fit object successfully. This is on OS X; Cython was upgraded (to Cython-0.25.2) as part of the PyStan upgrade. Has anyone seen anything like this before?

Many thanks for any help anyone can provide!

Stephen

Allen Riddell

unread,
Feb 17, 2017, 2:21:59 PM2/17/17
to stan-...@googlegroups.com
This sounds like a bug. Would you mind creating an issue on github?

https://github.com/stan-dev/pystan/issues
> --
> You received this message because you are subscribed to the Google
> Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to stan-users+...@googlegroups.com
> <mailto:stan-users+...@googlegroups.com>.
> To post to this group, send email to stan-...@googlegroups.com
> <mailto:stan-...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Stephen Feeney

unread,
Feb 17, 2017, 3:27:21 PM2/17/17
to Stan users mailing list
Hi Allen

I've done a bit more hunting here and I think I've found it. This actually only seems to occur for me when I use 'permuted = True'; not sure why I thought it happened with 'permuted=False', too. The error occurs for me in the line 

extracted[par] = extracted[par].reshape(newdim, order='F')

because newdim is a float. This seems to stem from fit.sim['n_save'] being assigned as a float in model.py, though I've not tracked down the source further than that.

Got a seminar now but will create a GitHub issue ASAP.

Cheers

Stephen

Reply all
Reply to author
Forward
0 new messages