Skip to content

Commit ec2feae

Browse files
committed
Separated group seed
1 parent 0713082 commit ec2feae

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

validphys2/src/validphys/n3fit_data.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ def replica_luxseed(replica, luxseed):
110110
return replica_nnseed(replica, luxseed)
111111

112112

113+
def group_replica_mcseed(replica_mcseed, groups_dataset_inputs_loaded_cd_with_cuts):
114+
names_for_salt = []
115+
for loaded_cd in groups_dataset_inputs_loaded_cd_with_cuts:
116+
if loaded_cd.legacy_names is None:
117+
names_for_salt.append(loaded_cd.setname)
118+
else:
119+
names_for_salt.append(loaded_cd.legacy_names[0])
120+
name_salt = "-".join(names_for_salt)
121+
122+
name_seed = int(hashlib.sha256(name_salt.encode()).hexdigest(), 16) % 10**8
123+
res = name_seed + replica_mcseed
124+
return res
125+
126+
113127
class _Masks(TupleComp):
114128
"""Class holding the training validation mask for a group of datasets
115129
If the same group of dataset receives the same trvlseed then the mask

validphys2/src/validphys/pseudodata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def read_replica_pseudodata(fit, context_index, replica):
122122

123123
def make_replica(
124124
groups_dataset_inputs_loaded_cd_with_cuts,
125-
replica_mcseed,
125+
group_replica_mcseed,
126126
dataset_inputs_sampling_covmat,
127127
sep_mult=False,
128128
genrep=True,
@@ -192,7 +192,7 @@ def make_replica(
192192
)
193193

194194
# 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)
195+
rng = np.random.default_rng(seed=group_replica_mcseed)
196196
# construct covmat
197197
covmat = dataset_inputs_sampling_covmat
198198
covmat_sqrt = sqrt_covmat(covmat)

0 commit comments

Comments
 (0)