Skip to content

Commit 67db676

Browse files
cailmdaleyclaude
andcommitted
fix: reconcile pr7-lineage SACC callers with guarded sacc_io API
The feat/sacc-3 merge brought the guard-era sacc_io whose save() now requires a keyword-only `type={'data','mock'}` provenance tag (PRD #241 §4) and whose load() refuses unblinded `type='data'`. Application code and tests from the pr4/pr7 lineage still called the old `save(s, path)` and referenced a template file the #236 cleanup had relocated, leaving 21 CI failures outside the merge-conflict set. This adapts the callers to the reviewed contract (sacc_io is unchanged). save() type= threading: - CosmologyValidation gains a `sacc_type` ctor kwarg (default "data"), stamped by every part-writer: cosebis/pure_eb/psf_systematics/pseudo_cl now `save(..., type=self.sacc_type)`. - assemble_sacc inherits provenance from its parts: `type=metadata["type"]`. - run_2pcf uses `cv.sacc_type`; run_2pcf_highres stamps "data" (real-catalogue fine covariance). - Synthetic-data tests adopt the reviewed idiom `type="mock"` (loads freely): test_sacc_writers _roundtrip + reload helper, test_assemble_sacc part writer, and the test_pseudo_cl fixture (`sacc_type="mock"`). Relocated FITS engine template: - The #236 folder cleanup moved cosmosis_pipeline_A_ia.ini into cosmosis_config/templates/ (still used by the legacy cosmosis_fitting.py path). The new pr7 Snakemake regime — inference.smk's INFERENCE_TEMPLATE_DIR, generate_inference_config, and its tests — resolves templates from cosmosis_config/ directly, where pr7 placed A_ia_sacc.ini but never copied its FITS sibling. Restore A_ia.ini alongside the sacc template. Fast suite: 254 passed, 1 skipped. Two remaining failures (test_calculate_pure_eb pinned-value drift; test_configured_paths_exist_on_candide) are pre-existing and environmental — they fail identically with these changes stashed, and neither is in the API-drift set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01766vawzi2XqrgoyHmeHEY9
1 parent 06b24c6 commit 67db676

12 files changed

Lines changed: 126 additions & 10 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#parameters used elsewhere in this file
2+
[DEFAULT]
3+
COSMOSIS_DIR = /n23data1/n06data/lgoh/scratch/cosmosis-standard-library_lisa
4+
5+
6+
[pipeline]
7+
modules = consistency sample_S8 camb load_nz_fits photoz_bias linear_alignment projection add_intrinsic 2pt_shear shear_m_bias 2pt_like
8+
likelihoods = 2pt_like
9+
extra_output = cosmological_parameters/omega_lambda cosmological_parameters/S_8 cosmological_parameters/sigma_8 cosmological_parameters/omega_m
10+
timing = T
11+
debug = T
12+
13+
[runtime]
14+
sampler = polychord
15+
verbosity = debug
16+
17+
[polychord]
18+
live_points = 192
19+
feedback = 3
20+
resume = T
21+
base_dir = %(SCRATCH)s/polychord
22+
23+
[test]
24+
25+
[output]
26+
format = text
27+
lock = F
28+
29+
[consistency]
30+
file = %(COSMOSIS_DIR)s/utility/consistency/consistency_interface.py
31+
verbose = F
32+
33+
[sample_S8]
34+
file = %(COSMOSIS_DIR)s/utility/sample_sigma8/sample_S8.py
35+
36+
[camb]
37+
file = %(COSMOSIS_DIR)s/boltzmann/camb/camb_interface.py
38+
mode=power
39+
lmax=2508
40+
feedback=0
41+
do_reionization=F
42+
kmin=1e-5
43+
kmax=20.0
44+
nk=200
45+
zmax=5.0
46+
zmax_background=5.0
47+
nz_background=500
48+
halofit_version=mead2020_feedback
49+
nonlinear=pk
50+
neutrino_hierarchy=normal
51+
kmax_extrapolate = 500.0
52+
53+
[load_nz_fits]
54+
file = %(COSMOSIS_DIR)s/number_density/load_nz_fits/load_nz_fits.py
55+
nz_file =%(FITS_FILE)s
56+
data_sets = SOURCE
57+
58+
[photoz_bias]
59+
file = %(COSMOSIS_DIR)s/number_density/photoz_bias/photoz_bias.py
60+
mode = additive
61+
sample = nz_source
62+
bias_section = nofz_shifts
63+
interpolation = cubic
64+
output_deltaz_section_name = delta_z_out
65+
66+
[linear_alignment]
67+
file = %(COSMOSIS_DIR)s/intrinsic_alignments/la_model/linear_alignments_interface_znla.py
68+
method = bk_corrected
69+
70+
[projection]
71+
file = %(COSMOSIS_DIR)s/structure/projection/project_2d.py
72+
ell_min_logspaced = 1.0
73+
ell_max_logspaced = 25000.0
74+
n_ell_logspaced = 400
75+
shear-shear = source-source
76+
shear-intrinsic = source-source
77+
intrinsic-intrinsic = source-source
78+
get_kernel_peaks = F
79+
verbose = F
80+
81+
[add_intrinsic]
82+
file = %(COSMOSIS_DIR)s/shear/add_intrinsic/add_intrinsic.py
83+
shear-shear=T
84+
position-shear=F
85+
perbin=F
86+
87+
[2pt_shear]
88+
file = %(COSMOSIS_DIR)s/shear/cl_to_xi_nicaea/nicaea_interface.so
89+
corr_type = 0 ; shear_cl -> shear_xi
90+
91+
[shear_m_bias]
92+
file = %(COSMOSIS_DIR)s/shear/shear_bias/shear_m_bias.py
93+
m_per_bin = True
94+
; Despite the parameter name, this can operate on xi as well as C_ell.
95+
cl_section = shear_xi_plus shear_xi_minus
96+
verbose = F
97+
98+
[2pt_like]
99+
file = %(COSMOSIS_DIR)s/likelihood/2pt/2pt_like.py
100+
data_file=%(FITS_FILE)s
101+
gaussian_covariance=F
102+
covmat_name=COVMAT
103+
cut_zeros=F
104+
data_sets=XI_PLUS XI_MINUS
105+
like_name=2pt_like
106+
107+
angle_range_XI_PLUS_1_1= 10.0 200.0
108+
angle_range_XI_MINUS_1_1= 20.0 200.0

src/sp_validation/cosmo_val/core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def __init__(
224224
path_onecovariance=None,
225225
cosmo_params=None,
226226
blind=None,
227+
sacc_type="data",
227228
):
228229
self.rho_tau_method = rho_tau_method
229230
self.cov_estimate_method = cov_estimate_method
@@ -253,6 +254,10 @@ def __init__(
253254
self.nside_mask = nside_mask
254255
self.path_onecovariance = path_onecovariance
255256
self.blind = blind
257+
# SACC provenance stamped by every part-writer via sacc_io.save(type=…):
258+
# 'data' for real catalogues (load-gated until blinded), 'mock' for
259+
# simulations (freely inspectable). PRD #241 §4.
260+
self.sacc_type = sacc_type
256261

257262
assert self.cell_method in ["map", "catalog"], (
258263
"cell_method must be 'map' or 'catalog'"

src/sp_validation/cosmo_val/cosebis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def cosebis_to_sacc_part(self, version, out_path, results, fiducial_scale_cut=No
180180
result,
181181
scale_cut,
182182
)
183-
sacc_io.save(s, out_path)
183+
sacc_io.save(s, out_path, type=self.sacc_type)
184184

185185
def plot_cosebis(
186186
self,

src/sp_validation/cosmo_val/pseudo_cl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def pseudo_cl_to_sacc_part(self, version, out_path, ell_eff, cl_all, wsp):
704704
cl_all,
705705
wsp,
706706
)
707-
sacc_io.save(s, out_path)
707+
sacc_io.save(s, out_path, type=self.sacc_type)
708708

709709
def plot_pseudo_cl(self):
710710
"""

src/sp_validation/cosmo_val/psf_systematics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def rho_tau_to_sacc_part(
8080
tau_cov_th=tau_cov_th,
8181
)
8282
out_path = os.path.join(out_dir, f"rho_tau_{base}.sacc")
83-
sacc_io.save(s, out_path)
83+
sacc_io.save(s, out_path, type=self.sacc_type)
8484

8585
@property
8686
def rho_stat_handler(self):

src/sp_validation/cosmo_val/pure_eb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def pure_eb_to_sacc_part(self, version, out_path, results):
151151
eb,
152152
covariance=results["cov"],
153153
)
154-
sacc_io.save(s, out_path)
154+
sacc_io.save(s, out_path, type=self.sacc_type)
155155

156156
def plot_pure_eb(
157157
self,

src/sp_validation/tests/test_assemble_sacc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_bandpower_windows(self):
131131
paths = {}
132132
for name, part in parts.items():
133133
p = tmp_path / f"{name}.sacc"
134-
sio.save(part, str(p))
134+
sio.save(part, str(p), type="mock")
135135
paths[name] = str(p)
136136
return paths
137137

src/sp_validation/tests/test_pseudo_cl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def cv(tmp_path):
169169
power=0.5,
170170
n_ell_bins=N_ELL_BINS,
171171
pol_factor=True,
172+
sacc_type="mock",
172173
)
173174
cv._test_version = version
174175
return cv

src/sp_validation/tests/test_sacc_writers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _theta(n=6):
3131

3232
def _roundtrip(s, tmp_path, name):
3333
p = tmp_path / f"{name}.sacc"
34-
sio.save(s, str(p))
34+
sio.save(s, str(p), type="mock")
3535
return sio.load(str(p))
3636

3737

@@ -306,7 +306,7 @@ def test_assemble_from_reloaded_parts(tmp_path):
306306
parts = _make_parts(nz)
307307
reloaded = []
308308
for i, part in enumerate(parts):
309-
sio.save(part, str(tmp_path / f"part{i}.sacc"))
309+
sio.save(part, str(tmp_path / f"part{i}.sacc"), type="mock")
310310
reloaded.append(sio.load(str(tmp_path / f"part{i}.sacc")))
311311
s = sw.assemble_analysis_sacc(nz, META, reloaded)
312312
assert type(s.covariance).__name__ == "FullCovariance"

workflow/scripts/assemble_sacc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ def assemble_sacc(
167167
if not parts:
168168
raise ValueError(f"no parts found for {version}: {part_paths}")
169169
s = assemble_analysis_sacc(nz, metadata, parts)
170-
sacc_io.save(s, out_path)
170+
# Provenance is inherited from the parts (all same version → same type).
171+
sacc_io.save(s, out_path, type=metadata["type"])
171172
print(f"Assembled {len(parts)} parts -> {out_path}")
172173
return s
173174

0 commit comments

Comments
 (0)