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
v3.0.0dev0 blobs failing when different shapes #256
Comments
I've "fixed" this in the sense that it doesn't fail anymore (instead it infers the dtype as |
I think this will work for the default backend, but not the HDF backend, as it does not understand the "object" dtype. I agree that there's no obvious way to do it that will work in all use cases. At this point, I am changing my likelihood function to present the blobs correctly. |
Yeah - this definitely won't work for the HDF backend but I don't see a way to fix that. I'll close this for now, but feel free to re-open if you think that there's more to do. |
as v3.0.0 is now the default pip version, this can cause transition issues for people previously (knowingly or unknowingly) worked with e.g. v2.2.1. The default blobs input leads to a raise statement. My travis report can be found here: Below the relevant lines that crashed ../../../virtualenv/python3.6.7/lib/python3.6/site-packages/emcee/ensemble.py:324: in sample |
Can you please provide a code snippet that reproduces this error? I'm not sure what you mean by "default" blobs. |
I mean the I never defined the blobs myself in v2.2.1. I see that you have a nice transition page and I will first to follow all those steps before coming back to you. It just became urgent to transition to v3.0.0 as the default pip version has changed (today?) and v2.2.1 is not supported anymore on python3 (at least not on travisCI environment) |
I don't see anything wrong with that line there and there are plenty of tests where the blobs are not definined and they work just fine. So, can you please share a small piece of code that reproduces your issue. |
The issue was in an incompatible wrapper that used two arguments in the likelihood function output and the way this functions were called to effectively overwrite the blobs statement. Problem fixed on my side. Sorry for bothering you and thanks for the quick replies. |
No worries. Glad you got it sorted! |
I keep having this issue when using CosmoHammer within MontePython, see issue mentioned above. I believe @sibirrer was experiencing the same issue. How exactly did you manage to fix it? |
@alessiospuriomancini: by now I am not using CosmoHammer anymore (as it might not be as well supported) and directly use the MPI support in emcee. The following way I initialize the MPI pool to work with emcee (slightly modified fro schwimmbad): https://github.com/sibirrer/lenstronomy/blob/master/lenstronomy/Sampling/Pool/multiprocessing.py |
Thanks so much @sibirrer. Just to clarify: you use the script |
yes @alessiospuriomancini, for example here: https://github.com/sibirrer/lenstronomy/blob/master/lenstronomy/Sampling/sampler.py in definition mcmc_emcee() |
General information:
Problem description:
Expected behavior:
I expect that returning blobs of various shapes should work.
Actual behavior:
An error is raised:
ValueError: setting an array element with a sequence.
What have you tried so far?:
When passing
blobs_dtype
with shapes for each returned blob, it works fine.Minimal example:
The offending line is L394 of
ensemble.py
:dt = np.atleast_1d(blob[0]).dtype
. This will work as intended (I think), if it is instead:dt = [(np.atleast_1d(b).dtype, np.atleast_1d(b).shape) for b in blob[0]]
, though there might need to be a check for 1-dimensional arrays.The text was updated successfully, but these errors were encountered: