Skip to content

Commit

Permalink
Hopefully fixed the doctest failures
Browse files Browse the repository at this point in the history
  • Loading branch information
manodeep committed Dec 10, 2017
1 parent b913788 commit c41273d
Showing 1 changed file with 62 additions and 61 deletions.
123 changes: 62 additions & 61 deletions Corrfunc/utils.py
Expand Up @@ -571,7 +571,7 @@ def compute_nbins(max_diff, binsize,
msg = 'Error: Invalid value for max_diff = {0} or binsize = {1}. '\
'Both must be positive'.format(max_diff, binsize)
raise ValueError(msg)
if max_nbins < 1:
if max_nbins is not None and max_nbins < 1:
msg = 'Error: Invalid for the max. number of bins allowed = {0}.'\
'Max. nbins must be >= 1'.format(max_nbins)
raise ValueError(msg)
Expand All @@ -582,7 +582,7 @@ def compute_nbins(max_diff, binsize,
raise ValueError(msg)

# At least 1 bin
ngrid = max(1, long(max_diff/binsize))
ngrid = max(1, int(max_diff/binsize))

# Then refine
ngrid *= refine_factor
Expand All @@ -592,7 +592,8 @@ def compute_nbins(max_diff, binsize,
if max_nbins:
ngrid = min(max_nbins, ngrid)

return ngrid
# Return the integer ngrid
return int(ngrid)


def gridlink_sphere(thetamax,
Expand Down Expand Up @@ -682,64 +683,64 @@ def gridlink_sphere(thetamax,
>>> import numpy as np
>>> np.set_printoptions(precision=8)
>>> thetamax=30
>>> 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])],
dtype=[(u'dec_limit', '<f8', (2,)), (u'ra_limit', '<f8', (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]),
([-1.57079633, -1.22173048], [ 4.71238898, 6.28318531]),
([-1.22173048, -0.87266463], [ 0. , 1.57079633]),
([-1.22173048, -0.87266463], [ 1.57079633, 3.14159265]),
([-1.22173048, -0.87266463], [ 3.14159265, 4.71238898]),
([-1.22173048, -0.87266463], [ 4.71238898, 6.28318531]),
([-0.87266463, -0.52359878], [ 0. , 1.57079633]),
([-0.87266463, -0.52359878], [ 1.57079633, 3.14159265]),
([-0.87266463, -0.52359878], [ 3.14159265, 4.71238898]),
([-0.87266463, -0.52359878], [ 4.71238898, 6.28318531]),
([-0.52359878, -0.17453293], [ 0. , 1.57079633]),
([-0.52359878, -0.17453293], [ 1.57079633, 3.14159265]),
([-0.52359878, -0.17453293], [ 3.14159265, 4.71238898]),
([-0.52359878, -0.17453293], [ 4.71238898, 6.28318531]),
([-0.17453293, 0.17453293], [ 0. , 1.57079633]),
([-0.17453293, 0.17453293], [ 1.57079633, 3.14159265]),
([-0.17453293, 0.17453293], [ 3.14159265, 4.71238898]),
([-0.17453293, 0.17453293], [ 4.71238898, 6.28318531]),
([ 0.17453293, 0.52359878], [ 0. , 1.57079633]),
([ 0.17453293, 0.52359878], [ 1.57079633, 3.14159265]),
([ 0.17453293, 0.52359878], [ 3.14159265, 4.71238898]),
([ 0.17453293, 0.52359878], [ 4.71238898, 6.28318531]),
([ 0.52359878, 0.87266463], [ 0. , 1.57079633]),
([ 0.52359878, 0.87266463], [ 1.57079633, 3.14159265]),
([ 0.52359878, 0.87266463], [ 3.14159265, 4.71238898]),
([ 0.52359878, 0.87266463], [ 4.71238898, 6.28318531]),
([ 0.87266463, 1.22173048], [ 0. , 1.57079633]),
([ 0.87266463, 1.22173048], [ 1.57079633, 3.14159265]),
([ 0.87266463, 1.22173048], [ 3.14159265, 4.71238898]),
([ 0.87266463, 1.22173048], [ 4.71238898, 6.28318531]),
([ 1.22173048, 1.57079633], [ 0. , 1.57079633]),
([ 1.22173048, 1.57079633], [ 1.57079633, 3.14159265]),
([ 1.22173048, 1.57079633], [ 3.14159265, 4.71238898]),
([ 1.22173048, 1.57079633], [ 4.71238898, 6.28318531])],
dtype=[(u'dec_limit', '<f8', (2,)), (u'ra_limit', '<f8', (2,))])
>>> grid = gridlink_sphere(thetamax) # doctest: +NORMALIZE_WHITESPACE
>>> print(grid)
[([-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])]
>>> grid = gridlink_sphere(60, dec_refine_factor=3, ra_refine_factor=2) # doctest: +NORMALIZE_WHITESPACE
>>> print(grid)
[([-1.57079633, -1.22173048], [ 0. , 1.57079633])
([-1.57079633, -1.22173048], [ 1.57079633, 3.14159265])
([-1.57079633, -1.22173048], [ 3.14159265, 4.71238898])
([-1.57079633, -1.22173048], [ 4.71238898, 6.28318531])
([-1.22173048, -0.87266463], [ 0. , 1.57079633])
([-1.22173048, -0.87266463], [ 1.57079633, 3.14159265])
([-1.22173048, -0.87266463], [ 3.14159265, 4.71238898])
([-1.22173048, -0.87266463], [ 4.71238898, 6.28318531])
([-0.87266463, -0.52359878], [ 0. , 1.57079633])
([-0.87266463, -0.52359878], [ 1.57079633, 3.14159265])
([-0.87266463, -0.52359878], [ 3.14159265, 4.71238898])
([-0.87266463, -0.52359878], [ 4.71238898, 6.28318531])
([-0.52359878, -0.17453293], [ 0. , 1.57079633])
([-0.52359878, -0.17453293], [ 1.57079633, 3.14159265])
([-0.52359878, -0.17453293], [ 3.14159265, 4.71238898])
([-0.52359878, -0.17453293], [ 4.71238898, 6.28318531])
([-0.17453293, 0.17453293], [ 0. , 1.57079633])
([-0.17453293, 0.17453293], [ 1.57079633, 3.14159265])
([-0.17453293, 0.17453293], [ 3.14159265, 4.71238898])
([-0.17453293, 0.17453293], [ 4.71238898, 6.28318531])
([ 0.17453293, 0.52359878], [ 0. , 1.57079633])
([ 0.17453293, 0.52359878], [ 1.57079633, 3.14159265])
([ 0.17453293, 0.52359878], [ 3.14159265, 4.71238898])
([ 0.17453293, 0.52359878], [ 4.71238898, 6.28318531])
([ 0.52359878, 0.87266463], [ 0. , 1.57079633])
([ 0.52359878, 0.87266463], [ 1.57079633, 3.14159265])
([ 0.52359878, 0.87266463], [ 3.14159265, 4.71238898])
([ 0.52359878, 0.87266463], [ 4.71238898, 6.28318531])
([ 0.87266463, 1.22173048], [ 0. , 1.57079633])
([ 0.87266463, 1.22173048], [ 1.57079633, 3.14159265])
([ 0.87266463, 1.22173048], [ 3.14159265, 4.71238898])
([ 0.87266463, 1.22173048], [ 4.71238898, 6.28318531])
([ 1.22173048, 1.57079633], [ 0. , 1.57079633])
([ 1.22173048, 1.57079633], [ 1.57079633, 3.14159265])
([ 1.22173048, 1.57079633], [ 3.14159265, 4.71238898])
([ 1.22173048, 1.57079633], [ 4.71238898, 6.28318531])]
"""

Expand Down

0 comments on commit c41273d

Please sign in to comment.