PolyChord / PolyChordLite

Public version of PolyChord: See polychord.co.uk for PolyChordPro
https://polychord.io/
Other
83 stars 26 forks source link

bugfixes for 2 corner cases #23

Closed JesusTorrado closed 5 years ago

JesusTorrado commented 5 years ago

This allows a numpy int array to be accepted (and casted) as a C float array, and solves a bug that appears when trying to count the name of parameters from a single-line equal-weights output file.

williamjameshandley commented 5 years ago

Hi @JesusTorrado. Your fix is currently failing on python 3 since you should use PyLong_Check, rather than PyInt_Check. This could be fixed by having a preprocessing flag to differentiate the two cases (see for example pypolychord/_pypolychord.cpp)

P.S. You might want to think about upgrading your codes to python3, since python2 is being deprecated this year

JesusTorrado commented 5 years ago

Thanks! PyLong_Check does not work either (apparently does not get that numpy.int64 is a Python integer). Investigating....

Sorry for the Py3 mishap. I constantly switch between both in my computer, while slowly phasing out 2.7.

williamjameshandley commented 5 years ago

Many thanks

JesusTorrado commented 5 years ago

Fixed for Py3 using PyNumber, which is a higher level API function.

But the conversion for grade_dim still fails due to the non-trivial conversion numpy.int64->int, so I need to cast my numpy array to a list of int's. I think the only option is to use the numpy C API.

Overall, it's an improvement, anyway.