Skip to content

Commit 0713082

Browse files
committed
Colibri compatible
1 parent 3ebb674 commit 0713082

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

validphys2/src/validphys/pseudodata.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,9 @@ def make_replica(
190190
return np.concatenate(
191191
[cd.central_values for cd in groups_dataset_inputs_loaded_cd_with_cuts]
192192
)
193-
# Seed the numpy RNG with the seed and the name of the datasets in this run
194-
195-
# TODO: to be simplified after the reader is merged, together with an update of the regression tests
196-
# this is necessary to reproduce exactly the results due to the replicas being generated with a hash
197-
# Only when the sets are legacy (or coming from a legacy runcard) this shall be used
198-
names_for_salt = []
199-
for loaded_cd in groups_dataset_inputs_loaded_cd_with_cuts:
200-
if loaded_cd.legacy_names is None:
201-
names_for_salt.append(loaded_cd.setname)
202-
else:
203-
names_for_salt.append(loaded_cd.legacy_names[0])
204-
name_salt = "-".join(names_for_salt)
205193

206-
name_seed = int(hashlib.sha256(name_salt.encode()).hexdigest(), 16) % 10**8
207-
rng = np.random.default_rng(seed=replica_mcseed + name_seed)
194+
# Set random seed to replica_mcseed - Would also like to change this seed for each group via 'groupname' (this can't yet be accessed here)
195+
rng = np.random.default_rng(seed=replica_mcseed)
208196
# construct covmat
209197
covmat = dataset_inputs_sampling_covmat
210198
covmat_sqrt = sqrt_covmat(covmat)
@@ -215,21 +203,29 @@ def make_replica(
215203
special_mult = []
216204
for cd in groups_dataset_inputs_loaded_cd_with_cuts:
217205
# copy here to avoid mutating the central values.
218-
pseudodata = cd.central_values.to_numpy()
206+
is_commondata = hasattr(cd, "central_values") and cd.central_values is not None
207+
if is_commondata:
208+
pseudodata = cd.central_values.to_numpy()
209+
else:
210+
pseudodata = np.asarray(cd)
219211

220212
pseudodatas.append(pseudodata)
221213
# Separation of multiplicative errors. If sep_mult is True also the exp_covmat is produced
222214
# without multiplicative errors
223-
if sep_mult:
224-
mult_errors = cd.multiplicative_errors
225-
mult_uncorr_errors = mult_errors.loc[:, mult_errors.columns == "UNCORR"].to_numpy()
226-
mult_corr_errors = mult_errors.loc[:, mult_errors.columns == "CORR"].to_numpy()
227-
nonspecial_mult.append((mult_uncorr_errors, mult_corr_errors))
228-
special_mult.append(
229-
mult_errors.loc[:, ~mult_errors.columns.isin(INTRA_DATASET_SYS_NAME)]
230-
)
231-
if "ASY" in cd.commondataproc or cd.commondataproc.endswith("_POL"):
232-
check_positive_masks.append(np.zeros_like(pseudodata, dtype=bool))
215+
if is_commondata == True:
216+
if sep_mult:
217+
mult_errors = cd.multiplicative_errors
218+
mult_uncorr_errors = mult_errors.loc[:, mult_errors.columns == "UNCORR"].to_numpy()
219+
mult_corr_errors = mult_errors.loc[:, mult_errors.columns == "CORR"].to_numpy()
220+
nonspecial_mult.append((mult_uncorr_errors, mult_corr_errors))
221+
special_mult.append(
222+
mult_errors.loc[:, ~mult_errors.columns.isin(INTRA_DATASET_SYS_NAME)]
223+
)
224+
if "ASY" in cd.commondataproc or cd.commondataproc.endswith("_POL"):
225+
check_positive_masks.append(np.zeros_like(pseudodata, dtype=bool))
226+
else:
227+
check_positive_masks.append(np.ones_like(pseudodata, dtype=bool))
228+
# If the input is not a commondata instance, then we assume there are no multiplicative errors and that all points must be positive
233229
else:
234230
check_positive_masks.append(np.ones_like(pseudodata, dtype=bool))
235231
# concatenating special multiplicative errors, pseudodatas and positive mask

0 commit comments

Comments
 (0)