manodeep / Corrfunc

⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
https://corrfunc.readthedocs.io
MIT License
165 stars 50 forks source link

pair weights not available as argument? #128

Closed ANSalcedo closed 7 years ago

ANSalcedo commented 7 years ago

When I run the following code:

import Corrfunc from Corrfunc._countpairs_mocks import countspairs_rp_pi_mocks as rp_pi_mocks

...

DD1 = rp_pi_mocks(1, 2, nthreads, pimax, binfile, RA1, DEC1, CZ1, RA1, DEC1, CZ1) DD1w = rp_pi_mocks(1, 2, nthreads, pimax, binfile, RA1, DEC1, CZ1, RA1, DEC1, CZ1, weights1=W1, weight_type = 'pair_product')

I receive the error:

File "5bins_wp_mock.py", line 118, in DD1w = rp_pi_mocks(1, 2, nthreads, pimax, binfile, RA1, DEC1, CZ1, RA1, DEC1, CZ1, weights1 = W1, weight_type = 'pair_product') TypeError: countpairs_rp_pi_mocks() takes no keyword arguments

When I run make tests, all the tests work fine. And when I run Corrfunc/mocks/python_bindings/call_correlation_functions_mocks.py I get no errors.

lgarrison commented 7 years ago

Try using the Python wrapper to the CPython module, i.e.

from Corrfunc.mocks.DDrppi_mocks import DDrppi_mocks

instead of

 from Corrfunc._countpairs_mocks import countspairs_rp_pi_mocks as rp_pi_mocks

The CPython argument parsing is rather rigid, so we have some pre-parsing in the Python wrapper to make it more user-friendly.

ANSalcedo commented 7 years ago

I made that change and it works fine. Thanks.

manodeep commented 7 years ago

@ANSalcedo All of the pair-counting interfaces can be accessed directly through the extensions, the wrappers under Corrfunc/mocks and Corrfunc/theory are the preferred way of calculating the pair-counts/correlation functions.

@lgarrison Perhaps we should make it more explicit in the docs? And/or remove the references to the extensions and only support the python wrappers...

lgarrison commented 7 years ago

I think all of the RTD docs are consistent about using the Python wrappers. It's just the call_correlation*.py examples that still use the extensions directly. The ones in Corrfunc/Corrfunc are probably easy to update, but the ones in Corrfunc/{mocks,theory}/python_bindings might need to stay as they are. To those we could add highly visible warnings at the top of the file.