question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trace plot from cmdstan results in IndexError: arrays used as indices must be of integer (or boolean) type

See original GitHub issue

I can’t plot the trace plot from cmdstan

ID = 3
posterior_glob =  "./samplesID_%d-[1-9].csv"%ID
obs_data_path = "./DataID_%d.R"%ID
cmdstan_data = az.from_cmdstan(posterior = posterior_glob, observed_data=obs_data_path)

pars = ["R0","kappa"]
az.plot_trace(cmdstan_data,var_names=pars)

which results in

/home/XXX/arviz/plots/kdeplot.py:326: RuntimeWarning: invalid value encountered in true_divide
  def _fast_kde_2d(x, y, gridsize=(128, 128), circular=False):

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-145-9641094159ee> in <module>
----> 1 az.plot_trace(cmdstan_data,var_names=pars)

~/anaconda3/lib/python3.6/site-packages/arviz/plots/traceplot.py in plot_trace(data, var_names, coords, divergences, figsize, textsize, lines, compact, combined, legend, plot_kwargs, fill_kwargs, rug_kwargs, hist_kwargs, trace_kwargs, max_plots)

IndexError: arrays used as indices must be of integer (or boolean) type

I can get density_plot with no problems, but trace plot does not work. It shows the first subplot for R0, but then displays the error.

Additional context Stable version 0.5.1 installed via pip-command

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ahartikainencommented, Nov 18, 2019

Yes, there is an error in from_cmdstan where part of the sample_stats items are float (they should be int or bool).

The quick fix to plot your results is

az.plot_trace(cmdstan_data,var_names=pars, divergences=False)
0reactions
aakhmetzcommented, Nov 18, 2019

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python,IndexError: arrays used as indices must be of integer ...
the problem was solved just by converting the float array into int ... select the elements in a different way than boolean index...
Read more >
IndexError: arrays used as indices must be of integer ... - GitHub
IndexError : arrays used as indices must be of integer (or boolean) ... Could you put some print() to see the type and...
Read more >
Arrays Used as Indices Must Be of Integer (Or Boolean) Type
The arrays used as indices must be of integer (or Boolean) type error is related to Numpy arrays. Click here to learn why...
Read more >
Solve IndexError: Arrays Used as Indices Must Be of Integer ...
This tutorial describes how to solve IndexError: arrays used as indices must be of integer (or boolean) type in Python.
Read more >
arrays used as indices must be of integer (or boolean) type"?
How to fix this "IndexError: arrays used as indices must be of ... Build the forward propagation in the tensorflow graph ### START...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found