Skip to content

Commit

Permalink
Attempting to fix #144
Browse files Browse the repository at this point in the history
  • Loading branch information
manodeep committed Dec 9, 2017
1 parent 5521b6a commit 138c362
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
9 changes: 4 additions & 5 deletions Corrfunc/io.py
Expand Up @@ -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')
Expand Down Expand Up @@ -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",
Expand Down
40 changes: 20 additions & 20 deletions Corrfunc/utils.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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', '<f8', (2,)), (u'ra_limit', '<f8', (2,))])
>>> 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]),
Expand Down
1 change: 1 addition & 0 deletions docs/source/modules/converting_3d_counts.rst
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion docs/source/modules/converting_ddtheta_mocks.rst
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions docs/source/modules/converting_rp_pi_counts.rst
Expand Up @@ -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
Expand Down

0 comments on commit 138c362

Please sign in to comment.