gwastro / pycbc

Core package to analyze gravitational-wave data, find signals, and study their parameters. This package was used in the first direct detection of gravitational waves (GW150914), and is used in the ongoing analysis of LIGO/Virgo data.
http://pycbc.org
GNU General Public License v3.0
314 stars 351 forks source link

cpnest sampler is broken #3797

Closed spxiwh closed 2 years ago

spxiwh commented 3 years ago

I was playing around with cpnest and hit a problem with this line https://github.com/gwastro/pycbc/blob/master/pycbc/inference/sampler/cpnest.py#L230

  File "/nfshome/store02/users/ian.harry/virtualenvs/pycbc_python3_dopp/lib/python3.6/site-packages/pycbc/inference/sampler/cpnest.py", line 232, in new_point
    [point[p] for p in self.model.sampling_params])
TypeError: Argument 'd' has incorrect type (expected array.array, got list)
Traceback (most recent call last):

Looking over the cpnest source code this function is actually a direct call to a cdefed function in Cython where all inputs must be certain types. Strangely it wants the input to be an array.array object, which I've never used before but seems a "not as good as numpy array, array". To fix this the second argument becomes:

array.array('d', [point[p] for p in self.model.sampling_params]) # The 'd' I think is the type declaration, double??

However, I'm not proposing this as a pull request at the moment because I don't know what version of cpnest this changed in, which may set a specific version to be required. Who is responsible for cpnest to assign this to?

ahnitz commented 3 years ago

@spxiwh You can assign to me if you like. This is a case where we should re-enable the sampler test for cpnest. (it was not enabled initially as cpnest doesn't work in python2 so was a pain to handle when we were still supporting that). I think we can just advance to the most recent cpnest release. They do not appear to occur that often.

ahnitz commented 3 years ago

i.e. update here to include the cpnest minimal example https://github.com/gwastro/pycbc/blob/master/examples/inference/samplers/run.sh

ahnitz commented 2 years ago

This has been fixed for some time.