More sanity checks in combine_and_shuffle()
@@ -1877,12 +1877,18 @@ def combine_and_shuffle(input_filenames, output_filename, k_factors=None, overwr
" settings, there will be wrong results! There are no explicit cross checks in place yet."
)
+ if len(input_filenames) <= 0:
+ raise ValueError("Need to provide at least one input filename")
+
# k factors
if k_factors is None:
k_factors = [1.0 for _ in input_filenames]
elif isinstance(k_factors, float):
k_factors = [k_factors for _ in input_filenames]
+ if len(input_filenames) != len(k_factors):
+ raise RuntimeError("Inconsistent length of input filenames and k factors: %s vs %s", len(input_filenames), len(k_factors))
+
# Copy first file to output_filename
logger.info("Copying setup from %s to %s", input_filenames[0], output_filename)
@@ -1968,6 +1974,8 @@ def combine_and_shuffle(input_filenames, output_filename, k_factors=None, overwr
def _calculate_n_events(sampling_ids, n_benchmarks):
+ if sampling_ids is None:
+ return None, None
unique, counts = np.unique(sampling_ids, return_counts=True)
results = dict(zip(unique, counts))
n_events_backgrounds = results.get(-1,0)
