Commit f82a8e54 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cleanup

parent cc6aad10
......@@ -3,49 +3,49 @@ import numpy as np
import math
def random_ptg(vlen):
res=np.empty((vlen,2),dtype=np.float64)
res[:,0]=np.arccos((np.random.random_sample(vlen)-0.5)*2)
res[:,1]=np.random.random_sample(vlen)*2*math.pi
res = np.empty((vlen, 2), dtype=np.float64)
res[:,0] = np.arccos((np.random.random_sample(vlen)-0.5)*2)
res[:,1] = np.random.random_sample(vlen)*2*math.pi
return res
def check_pixangpix(vlen,ntry,nside,isnest):
base=ph.Healpix_Base (nside,"NEST" if isnest else "RING")
cnt=0
while (cnt<ntry):
cnt+=1
inp=np.random.randint(low=0,high=12*nside*nside-1,size=vlen)
out=base.ang2pix(base.pix2ang(inp))
if (np.array_equal(inp,out)==False):
base = ph.Healpix_Base (nside, "NEST" if isnest else "RING")
cnt = 0
while cnt < ntry:
cnt += 1
inp = np.random.randint(low=0, high=12*nside*nside-1, size=vlen)
out = base.ang2pix(base.pix2ang(inp))
if not np.array_equal(inp, out):
raise ValueError("Test failed")
def check_vecpixvec(vlen,ntry,nside,isnest):
base=ph.Healpix_Base (nside,"NEST" if isnest else "RING")
cnt=0
while (cnt<ntry):
cnt+=1
inp=ph.ang2vec(random_ptg(vlen))
out=base.pix2vec(base.vec2pix(inp))
if (np.any(np.greater(ph.v_angle(inp,out),base.max_pixrad()))):
def check_vecpixvec(vlen, ntry, nside, isnest):
base = ph.Healpix_Base (nside, "NEST" if isnest else "RING")
cnt = 0
while cnt < ntry:
cnt += 1
inp = ph.ang2vec(random_ptg(vlen))
out = base.pix2vec(base.vec2pix(inp))
if np.any(ph.v_angle(inp,out) > base.max_pixrad()):
raise ValueError("Test failed")
def check_pixangvecpix(vlen,ntry,nside,isnest):
base=ph.Healpix_Base (nside,"NEST" if isnest else "RING")
cnt=0
while (cnt<ntry):
cnt+=1
inp=np.random.randint(low=0,high=12*nside*nside-1,size=vlen)
out=base.vec2pix(ph.ang2vec(base.pix2ang(inp)))
if (np.array_equal(inp,out)==False):
def check_pixangvecpix(vlen, ntry, nside, isnest):
base = ph.Healpix_Base (nside, "NEST" if isnest else "RING")
cnt = 0
while cnt < ntry:
cnt += 1
inp = np.random.randint(low=0, high=12*nside*nside-1, size=vlen)
out = base.vec2pix(ph.ang2vec(base.pix2ang(inp)))
if not np.array_equal(inp,out):
raise ValueError("Test failed")
def check_pixvecangpix(vlen,ntry,nside,isnest):
base=ph.Healpix_Base (nside,"NEST" if isnest else "RING")
cnt=0
while (cnt<ntry):
cnt+=1
inp=np.random.randint(low=0,high=12*nside*nside-1,size=vlen)
out=base.ang2pix(ph.vec2ang(base.pix2vec(inp)))
if (np.array_equal(inp,out)==False):
def check_pixvecangpix(vlen, ntry, nside, isnest):
base = ph.Healpix_Base (nside, "NEST" if isnest else "RING")
cnt = 0
while cnt < ntry:
cnt += 1
inp = np.random.randint(low=0, high=12*nside*nside-1, size=vlen)
out = base.ang2pix(ph.vec2ang(base.pix2vec(inp)))
if not np.array_equal(inp,out):
raise ValueError("Test failed")
def check_pixvecpix(vlen,ntry,nside,isnest):
......
......@@ -9,6 +9,7 @@ import distutils.sysconfig
import itertools
from glob import iglob
def _get_sharp_libname():
builder = setuptools.command.build_ext.build_ext(Distribution())
full_name = builder.get_ext_filename('libsharp')
......@@ -24,9 +25,11 @@ def _get_distutils_build_directory():
other ones.
"""
pattern = "lib.{platform}-{major}.{minor}"
return os.path.join('build', pattern.format(platform=sysconfig.get_platform(),
major=sys.version_info[0],
minor=sys.version_info[1]))
return os.path.join(
'build', pattern.format(platform=sysconfig.get_platform(),
major=sys.version_info[0],
minor=sys.version_info[1]))
class _deferred_pybind11_include(object):
def __init__(self, user=False):
......@@ -36,6 +39,7 @@ class _deferred_pybind11_include(object):
import pybind11
return pybind11.get_include(self.user)
def _strip_inc(input):
res = []
for i in input:
......@@ -67,13 +71,15 @@ def _remove_strict_prototype_option_from_distutils_config():
if strict_prototypes in str(value):
config[key] = config[key].replace(strict_prototypes, '')
_remove_strict_prototype_option_from_distutils_config()
#extra_compile_args = ['-fopenmp', '-march=native']
#openmp_libs=['gomp']
extra_compile_args=[]
openmp_libs=[]
extra_c_compile_args=[]
# extra_compile_args = ['-fopenmp', '-march=native']
# openmp_libs=['gomp']
extra_compile_args = []
openmp_libs = []
extra_c_compile_args = []
extra_cc_compile_args = []
include_dirs = ['c_utils/', './', 'libsharp/', 'cxxsupport',
'Healpix_cxx', _deferred_pybind11_include(),
......@@ -97,8 +103,8 @@ if sys.platform == 'darwin':
'-Wl,-dylib_install_name,@loader_path/{}'.format(full_name))
base_library_link_args.append('-dynamiclib')
else:
extra_compile_args+=['-fopenmp', '-march=native']
python_module_link_args+=['-fopenmp', '-march=native']
extra_compile_args += ['-fopenmp', '-march=native']
python_module_link_args += ['-fopenmp', '-march=native']
extra_c_compile_args.append('--std=c99')
extra_cc_compile_args.append('--std=c++14')
python_module_link_args.append("-Wl,-rpath,$ORIGIN")
......
......@@ -15,55 +15,58 @@ def list2fixture(lst):
return myfixture
nside_nest = list2fixture([1, 2, 4, 8, 16, 32, 64, 2048, 1<<28])
nside_ring = list2fixture([1, 2, 4, 8, 16, 32, 64, 2048, 1<<28, 317])
pow2 = [1 << shift for shift in range(29)]
nonpow2 = [i+7 for i in pow2]
nside_nest = list2fixture(pow2)
nside_ring = list2fixture(pow2+nonpow2)
vlen = list2fixture([1, 10, 100, 1000])
vlen = list2fixture([1, 10, 100, 1000, 10000])
def random_ptg(vlen):
res = np.empty((vlen, 2), dtype=np.float64)
res[:, 0] = np.arccos((np.random.random_sample(vlen)-0.5)*2)
# res[:, 0] = math.pi*np.random.random_sample(vlen)
res[:, 1] = np.random.random_sample(vlen)*2*math.pi
return res
def test_pixangpix_nest(vlen,nside_nest):
base = ph.Healpix_Base (nside_nest, "NEST")
def test_pixangpix_nest(vlen, nside_nest):
base = ph.Healpix_Base(nside_nest, "NEST")
inp = np.random.randint(low=0, high=12*nside_nest*nside_nest-1, size=vlen)
out = base.ang2pix(base.pix2ang(inp))
assert_equal(inp, out)
def test_pixangpix_ring(vlen,nside_ring):
base = ph.Healpix_Base (nside_ring, "RING")
def test_pixangpix_ring(vlen, nside_ring):
base = ph.Healpix_Base(nside_ring, "RING")
inp = np.random.randint(low=0, high=12*nside_ring*nside_ring-1, size=vlen)
out = base.ang2pix(base.pix2ang(inp))
assert_equal(inp, out)
def test_vecpixvec_nest(vlen, nside_nest):
base = ph.Healpix_Base (nside_nest, "NEST")
base = ph.Healpix_Base(nside_nest, "NEST")
inp = ph.ang2vec(random_ptg(vlen))
out = base.pix2vec(base.vec2pix(inp))
assert_equal(np.all(ph.v_angle(inp,out) < base.max_pixrad()), True)
assert_equal(np.all(ph.v_angle(inp, out) < base.max_pixrad()), True)
def test_vecpixvec_ring(vlen, nside_ring):
base = ph.Healpix_Base (nside_ring, "RING")
base = ph.Healpix_Base(nside_ring, "RING")
inp = ph.ang2vec(random_ptg(vlen))
out = base.pix2vec(base.vec2pix(inp))
assert_equal(np.all(ph.v_angle(inp,out) < base.max_pixrad()), True)
assert_equal(np.all(ph.v_angle(inp, out) < base.max_pixrad()), True)
def test_ringnestring(vlen, nside_nest):
base = ph.Healpix_Base (nside_nest, "NEST")
inp=np.random.randint(low=0,high=12*nside_nest*nside_nest-1,size=vlen)
out=base.ring2nest(base.nest2ring(inp))
base = ph.Healpix_Base(nside_nest, "NEST")
inp = np.random.randint(low=0, high=12*nside_nest*nside_nest-1, size=vlen)
out = base.ring2nest(base.nest2ring(inp))
assert_equal(np.all(out == inp), True)
def test_vecangvec(vlen):
inp=random_ptg(vlen)
out=ph.vec2ang(ph.ang2vec(inp))
assert_equal(np.all(np.abs(out-inp)<1e-10), True)
inp = random_ptg(vlen)
out = ph.vec2ang(ph.ang2vec(inp))
assert_equal(np.all(np.abs(out-inp) < 1e-14), True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment