-
Notifications
You must be signed in to change notification settings - Fork 16
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
merge_samples_weighted does not reset_index which breaks sample compression #189
Comments
There's another problem: |
Hi @Stefan-Heimersheim. The weights problem looks like you are using quite an old version of anesthetic -- do you get this problem if you use the master branch? You can get this by installing: pip install anesthetic==2.0.0b11
#or
pip install pip install git+https://github.com/williamjameshandley/anesthetic@master (We plan to properly release anesthetic 2.0.0 over the summer once we've finalised all the interface-breaking changes). I agree that we should replace the |
I appear to have the latest version:
I just did |
I've had a chance to look into this properly -- you are right that it does occur on the latest version. The If we want to go with reindexing it's a little bit more involved to ensure that the weights are passed on correctly. Here is the correct code: merge_prior = anesthetic.samples.merge_samples_weighted(prior_samples, weights=np.ones(51))
merge_prior = merge_prior.reset_index().set_index("weights", append=True).drop(columns="#")
merge_prior.index.set_names(["#", "weights"], inplace=True) However, I don't think this is the right thing to do. One might want to preserve the original index labelling, and the plotting commands shouldn't be failing here. The correct thing to do is to put x = np.array(x)
y = np.array(y) at the start of If you agree, please go ahead and submit a PR with this minor change. Here is an even more minimal test which reproduces this error, which passes after the fix: samples = anesthetic.MCMCSamples(np.random.rand(1000,2),columns=["x","y"],index=np.random.randint(0,100,1000))
samples.plot_2d(["x", "y"]) Ideally we would run the entire test suite through with the assumption that the |
Ah right, I had just added an
Will do! |
Describe the bug
merge_samples_weighted
2 data sets with N samples each produces indices0,1,2,...,N,0,1,2,...N
rather than0,1,2,...,2N
.To Reproduce
gives
IndexError: index 5330 is out of bounds for axis 0 with size 1000
intriangular_sample_compression_2d
:This can be solved by adding a
reset_index()
to the merge, re-indexing the samples correctlyAs soon as I get time I will make a PR to fix this bug.
Note: We use
df.append
inmerge_samples_weighted
which is now deprecated and we should replace that function as well.The text was updated successfully, but these errors were encountered: