From 138c3623fa2f2de8bcac58ab0d3170d7185a1290 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Sat, 9 Dec 2017 21:11:41 +1100 Subject: [PATCH] Attempting to fix #144 --- Corrfunc/io.py | 9 ++--- Corrfunc/utils.py | 40 +++++++++---------- docs/source/modules/converting_3d_counts.rst | 1 + .../modules/converting_ddtheta_mocks.rst | 7 +++- .../modules/converting_rp_pi_counts.rst | 2 + 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Corrfunc/io.py b/Corrfunc/io.py index 7cd4bce8..69eab92a 100644 --- a/Corrfunc/io.py +++ b/Corrfunc/io.py @@ -10,6 +10,10 @@ from os.path import dirname, abspath, splitext, exists as file_exists,\ join as pjoin import numpy as np +try: + import pandas as pd +except ImportError: + pd = None __all__ = ('read_fastfood_catalog', 'read_ascii_catalog', 'read_catalog') @@ -220,11 +224,6 @@ def read_ascii_catalog(filename, return_dtype=None): # check if pandas is available - much faster to read in the data # using pandas - try: - import pandas as pd - except ImportError: - pd = None - if pd is not None: df = pd.read_csv(filename, header=None, engine="c", diff --git a/Corrfunc/utils.py b/Corrfunc/utils.py index d237ba10..f9292329 100644 --- a/Corrfunc/utils.py +++ b/Corrfunc/utils.py @@ -558,7 +558,7 @@ def compute_nbins(max_diff, binsize, >>> max_diff = 180 >>> binsize = 10 >>> compute_nbins(max_diff, binsize) - 18 + 18L >>> refine_factor=2 >>> max_nbins = 20 >>> compute_nbins(max_diff, binsize, refine_factor=refine_factor, @@ -680,27 +680,27 @@ def gridlink_sphere(thetamax, >>> from Corrfunc.utils import gridlink_sphere >>> thetamax=30 - >>> gridlink_sphere(thetamax) + >>> gridlink_sphere(thetamax) # doctest: +NORMALIZE_WHITESPACE array([([-1.57079633, -1.04719755], [ 0. , 3.14159265]), - ([-1.57079633, -1.04719755], [ 3.14159265, 6.28318531]), - ([-1.04719755, -0.52359878], [ 0. , 3.14159265]), - ([-1.04719755, -0.52359878], [ 3.14159265, 6.28318531]), - ([-0.52359878, 0. ], [ 0. , 1.25663706]), - ([-0.52359878, 0. ], [ 1.25663706, 2.51327412]), - ([-0.52359878, 0. ], [ 2.51327412, 3.76991118]), - ([-0.52359878, 0. ], [ 3.76991118, 5.02654825]), - ([-0.52359878, 0. ], [ 5.02654825, 6.28318531]), - ([ 0. , 0.52359878], [ 0. , 1.25663706]), - ([ 0. , 0.52359878], [ 1.25663706, 2.51327412]), - ([ 0. , 0.52359878], [ 2.51327412, 3.76991118]), - ([ 0. , 0.52359878], [ 3.76991118, 5.02654825]), - ([ 0. , 0.52359878], [ 5.02654825, 6.28318531]), - ([ 0.52359878, 1.04719755], [ 0. , 3.14159265]), - ([ 0.52359878, 1.04719755], [ 3.14159265, 6.28318531]), - ([ 1.04719755, 1.57079633], [ 0. , 3.14159265]), - ([ 1.04719755, 1.57079633], [ 3.14159265, 6.28318531])], + ([-1.57079633, -1.04719755], [ 3.14159265, 6.28318531]), + ([-1.04719755, -0.52359878], [ 0. , 3.14159265]), + ([-1.04719755, -0.52359878], [ 3.14159265, 6.28318531]), + ([-0.52359878, 0. ], [ 0. , 1.25663706]), + ([-0.52359878, 0. ], [ 1.25663706, 2.51327412]), + ([-0.52359878, 0. ], [ 2.51327412, 3.76991118]), + ([-0.52359878, 0. ], [ 3.76991118, 5.02654825]), + ([-0.52359878, 0. ], [ 5.02654825, 6.28318531]), + ([ 0. , 0.52359878], [ 0. , 1.25663706]), + ([ 0. , 0.52359878], [ 1.25663706, 2.51327412]), + ([ 0. , 0.52359878], [ 2.51327412, 3.76991118]), + ([ 0. , 0.52359878], [ 3.76991118, 5.02654825]), + ([ 0. , 0.52359878], [ 5.02654825, 6.28318531]), + ([ 0.52359878, 1.04719755], [ 0. , 3.14159265]), + ([ 0.52359878, 1.04719755], [ 3.14159265, 6.28318531]), + ([ 1.04719755, 1.57079633], [ 0. , 3.14159265]), + ([ 1.04719755, 1.57079633], [ 3.14159265, 6.28318531])], dtype=[(u'dec_limit', '>> gridlink_sphere(60, dec_refine_factor=3, ra_refine_factor=2) + >>> gridlink_sphere(60, dec_refine_factor=3, ra_refine_factor=2) # doctest: +NORMALIZE_WHITESPACE array([([-1.57079633, -1.22173048], [ 0. , 1.57079633]), ([-1.57079633, -1.22173048], [ 1.57079633, 3.14159265]), ([-1.57079633, -1.22173048], [ 3.14159265, 4.71238898]), diff --git a/docs/source/modules/converting_3d_counts.rst b/docs/source/modules/converting_3d_counts.rst index b9a20420..23695d49 100644 --- a/docs/source/modules/converting_3d_counts.rst +++ b/docs/source/modules/converting_3d_counts.rst @@ -18,6 +18,7 @@ wrapper :py:mod:`Corrfunc.theory.DD` >>> # Read the supplied galaxies on a periodic box >>> X, Y, Z = read_catalog() + >>> N = len(X) >>> boxsize = 420.0 >>> nthreads = 2 diff --git a/docs/source/modules/converting_ddtheta_mocks.rst b/docs/source/modules/converting_ddtheta_mocks.rst index 9e60abad..4dd4f559 100644 --- a/docs/source/modules/converting_ddtheta_mocks.rst +++ b/docs/source/modules/converting_ddtheta_mocks.rst @@ -12,6 +12,7 @@ wrapper :py:mod:`Corrfunc.mocks.DDtheta_mocks` .. code-block:: python >>> from os.path import dirname, abspath, join as pjoin + >>> import numpy as np >>> import Corrfunc >>> from Corrfunc.mocks.DDtheta_mocks import DDtheta_mocks >>> from Corrfunc.io import read_catalog @@ -28,11 +29,15 @@ wrapper :py:mod:`Corrfunc.mocks.DDtheta_mocks` >>> random_catalog=pjoin(dirname(abspath(Corrfunc.__file__)), ... "../mocks/tests/data", "Mr19_randoms_northonly.rdcz.ff") >>> rand_RA, rand_DEC, _ = read_catalog(random_catalog) - + >>> rand_N = len(rand_RA) + # Setup the bins >>> nbins = 10 >>> bins = np.linspace(0.1, 10.0, nbins + 1) # note the +1 to nbins + # Number of threads to use + >>> nthreads = 2 + # Auto pair counts in DD >>> autocorr=1 >>> DD_counts = DDtheta_mocks(autocorr, nthreads, bins, diff --git a/docs/source/modules/converting_rp_pi_counts.rst b/docs/source/modules/converting_rp_pi_counts.rst index 77cc492d..0450e597 100644 --- a/docs/source/modules/converting_rp_pi_counts.rst +++ b/docs/source/modules/converting_rp_pi_counts.rst @@ -8,12 +8,14 @@ by using the helper function :py:mod:`Corrfunc.utils.convert_rp_pi_counts_to_wp` .. code-block:: python + >>> import numpy as np >>> from Corrfunc.theory import DDrppi >>> from Corrfunc.io import read_catalog >>> from Corrfunc.utils import convert_rp_pi_counts_to_wp # Read the supplied galaxies on a periodic box >>> X, Y, Z = read_catalog() + >>> N = len(X) >>> boxsize = 420.0 # Generate randoms on the box