Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Jan 3, 2024
1 parent b586bdc commit 0de0638
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions tests/test_patch3pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,20 @@ def test_kkk_jk():
with assert_raises(RuntimeError):
kkkp.process(catq, catq, catp)

# Don't check LogSAS for accuracy. Just make sure the code runs.
print('LogSAS')
kkkp2 = treecorr.KKKCorrelation(nbins=3, min_sep=50., max_sep=100., bin_slop=0.2,
min_phi=0.8, max_phi=2.0, nphi_bins=3,
rng=rng, bin_type='LogSAS')
kkkp2.process(catp)
cov = kkkp2.estimate_cov('jackknife', func=lambda c: c.weight.ravel())
A, w = kkkp2.build_cov_design_matrix('jackknife', func=lambda c: c.weight.ravel())
vmean = np.mean(A, axis=0)
A -= vmean
cov2 = (catp.npatch-1)/catp.npatch * A.conj().T.dot(A)
np.testing.assert_allclose(cov2, cov)


@timer
def test_ggg_jk():
# Test jackknife and other covariance estimates for ggg correlations.
Expand Down Expand Up @@ -911,6 +925,19 @@ def test_ggg_jk():
print('max log(ratio) = ',np.max(np.abs(np.log(np.diagonal(cov))-np.log(var_ggg))))
np.testing.assert_allclose(np.log(np.diagonal(cov)), np.log(var_ggg), atol=0.5*tol_factor)

# Don't check LogSAS for accuracy. Just make sure the code runs.
print('LogSAS')
gggp2 = treecorr.GGGCorrelation(nbins=3, min_sep=50., max_sep=100., bin_slop=0.2,
min_phi=0.8, max_phi=2.0, nphi_bins=3,
rng=rng, bin_type='LogSAS')
gggp2.process(catp)
cov = gggp2.estimate_cov('jackknife', func=lambda c: c.weight.ravel())
A, w = gggp2.build_cov_design_matrix('jackknife', func=lambda c: c.weight.ravel())
vmean = np.mean(A, axis=0)
A -= vmean
cov2 = (catp.npatch-1)/catp.npatch * A.conj().T.dot(A)
np.testing.assert_allclose(cov2, cov)


@timer
def test_nnn_jk():
Expand Down Expand Up @@ -1344,6 +1371,18 @@ def test_nnn_jk():
cov5 = ddd5.estimate_cov('jackknife')
np.testing.assert_allclose(cov5, cov1)

# Don't check LogSAS for accuracy. Just make sure the code runs.
print('LogSAS')
dddp2 = treecorr.NNNCorrelation(nbins=3, min_sep=50., max_sep=100., bin_slop=0.2,
min_phi=0.8, max_phi=2.0, nphi_bins=3,
rng=rng, bin_type='LogSAS')
dddp2.process(catp)
cov = dddp2.estimate_cov('jackknife', func=lambda c: c.weight.ravel())
A, w = dddp2.build_cov_design_matrix('jackknife', func=lambda c: c.weight.ravel())
vmean = np.mean(A, axis=0)
A -= vmean
cov2 = (catp.npatch-1)/catp.npatch * A.conj().T.dot(A)
np.testing.assert_allclose(cov2, cov)

@timer
def test_brute_jk():
Expand Down
2 changes: 1 addition & 1 deletion treecorr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def set_omp_threads(num_threads, logger=None):

# See comment about this in get_omp_threads. Do it here too.
var = "OMP_PROC_BIND"
if var not in os.environ:
if var not in os.environ: # pragma: no cover
os.environ[var] = "false"
num_threads = _treecorr.SetOMPThreads(num_threads)

Expand Down

0 comments on commit 0de0638

Please sign in to comment.