From bb8b36bc072fe2a5144259f241393eb803f909c8 Mon Sep 17 00:00:00 2001 From: dz24 Date: Tue, 10 Mar 2026 18:47:56 +0900 Subject: [PATCH 1/5] first --- inftools/tistools/path_weights.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inftools/tistools/path_weights.py b/inftools/tistools/path_weights.py index cbe64df..98db952 100644 --- a/inftools/tistools/path_weights.py +++ b/inftools/tistools/path_weights.py @@ -40,6 +40,7 @@ def get_path_weights( data = data[nskip:] # we only need non-zero paths non_zero_paths = data[:, 3] == "----" + minus_paths = data[:, 3] != "----" data[data == "----"] = "0.0" D = {} @@ -85,10 +86,20 @@ def get_path_weights( ) A[j] = Q[K] * np.sum(w[j]) + # add minus to weights + minus_pn = data[minus_paths, 0:1].astype(int) + denominator = np.sum(data[minus_paths, 3].astype(float)) + minus_op = data[minus_paths, 2:3].astype(float) + minus_w = data[minus_paths, 3:4].astype(float)/denominator + + combined_pnr = np.concatenate([D["pnr"], minus_pn]) + combined_mop = np.concatenate([D["maxop"], minus_op]) + combined_wei = np.concatenate([A, minus_w]) + print(f"Weights saved to {out}.") np.savetxt( out, - np.c_[D["pnr"], D["maxop"], A], + np.c_[combined_pnr, combined_mop, combined_wei], header="path_nr\tmax_op\tweight", fmt=["%8d", "%9.5f", "%16.8e"], ) From 51d24cf64450c47ac24c5d7385f184f15e155b9e Mon Sep 17 00:00:00 2001 From: dz24 Date: Tue, 10 Mar 2026 19:19:15 +0900 Subject: [PATCH 2/5] update --- inftools/tistools/path_weights.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/inftools/tistools/path_weights.py b/inftools/tistools/path_weights.py index 98db952..f6841c2 100644 --- a/inftools/tistools/path_weights.py +++ b/inftools/tistools/path_weights.py @@ -10,7 +10,8 @@ def get_path_weights( nskip: Annotated[ int, typer.Option( "-nskip", help="Skip the first nskip entries of the infretis_data.txt file",), ] = 0, plotP: Annotated[ bool, typer.Option( "-plotP", help="If true plot the binless crossing probability"), ] = False, outP: Annotated[ str, typer.Option( "-outP", help="Write the binless WHAM crossing probability to outP"), ] = "", - overw: Annotated[ bool, typer.Option("-O", help="Force overwriting of files") ] = False,): + overw: Annotated[ bool, typer.Option("-O", help="Force overwriting of files") ] = False, + minus: Annotated[ bool, typer.Option("-minus", help="Add the minus path weigths") ] = False): """Calculate the unbiased weight for paths in the plus ensembles. The weights can be used to calculate observables as = sum(wi*Oi), for @@ -92,14 +93,18 @@ def get_path_weights( minus_op = data[minus_paths, 2:3].astype(float) minus_w = data[minus_paths, 3:4].astype(float)/denominator - combined_pnr = np.concatenate([D["pnr"], minus_pn]) - combined_mop = np.concatenate([D["maxop"], minus_op]) - combined_wei = np.concatenate([A, minus_w]) + if minus: + combined_pnr = np.concatenate([D["pnr"], minus_pn]) + combined_mop = np.concatenate([D["maxop"], minus_op]) + combined_wei = np.concatenate([A, minus_w]) + D["pnr"] = combined_pnr + D["maxop"] = combined_mop + A = combined_wei print(f"Weights saved to {out}.") np.savetxt( out, - np.c_[combined_pnr, combined_mop, combined_wei], + np.c_[D["pnr"], D["maxop"], A], header="path_nr\tmax_op\tweight", fmt=["%8d", "%9.5f", "%16.8e"], ) From 1c2ec60c1e131cf4ed6c7268e72a36fc26c09e26 Mon Sep 17 00:00:00 2001 From: dz24 Date: Tue, 10 Mar 2026 19:22:15 +0900 Subject: [PATCH 3/5] update --- inftools/tistools/path_weights.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/inftools/tistools/path_weights.py b/inftools/tistools/path_weights.py index f6841c2..7f0261d 100644 --- a/inftools/tistools/path_weights.py +++ b/inftools/tistools/path_weights.py @@ -94,12 +94,9 @@ def get_path_weights( minus_w = data[minus_paths, 3:4].astype(float)/denominator if minus: - combined_pnr = np.concatenate([D["pnr"], minus_pn]) - combined_mop = np.concatenate([D["maxop"], minus_op]) - combined_wei = np.concatenate([A, minus_w]) - D["pnr"] = combined_pnr - D["maxop"] = combined_mop - A = combined_wei + D["pnr"] = np.concatenate([D["pnr"], minus_pn]) + D["maxop"] = np.concatenate([D["maxop"], minus_op]) + A = np.concatenate([A, minus_w]) print(f"Weights saved to {out}.") np.savetxt( From 6fa0ebd743f58d4fe06c397475911870352c60fd Mon Sep 17 00:00:00 2001 From: dz24 Date: Tue, 10 Mar 2026 19:33:58 +0900 Subject: [PATCH 4/5] push --- inftools/tistools/path_weights.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/inftools/tistools/path_weights.py b/inftools/tistools/path_weights.py index 7f0261d..a5d33bb 100644 --- a/inftools/tistools/path_weights.py +++ b/inftools/tistools/path_weights.py @@ -88,12 +88,11 @@ def get_path_weights( A[j] = Q[K] * np.sum(w[j]) # add minus to weights - minus_pn = data[minus_paths, 0:1].astype(int) - denominator = np.sum(data[minus_paths, 3].astype(float)) - minus_op = data[minus_paths, 2:3].astype(float) - minus_w = data[minus_paths, 3:4].astype(float)/denominator - if minus: + minus_pn = data[minus_paths, 0:1].astype(int) + denominator = np.sum(data[minus_paths, 3].astype(float)) + minus_op = data[minus_paths, 2:3].astype(float) + minus_w = data[minus_paths, 3:4].astype(float)/denominator D["pnr"] = np.concatenate([D["pnr"], minus_pn]) D["maxop"] = np.concatenate([D["maxop"], minus_op]) A = np.concatenate([A, minus_w]) From b7d9f3f3bad3458b54f95dae21b11837f8776cd4 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf <74910029+lukasbaldauf@users.noreply.github.com> Date: Tue, 10 Mar 2026 11:57:29 +0100 Subject: [PATCH 5/5] Refactor minus_paths assignment for clarity --- inftools/tistools/path_weights.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inftools/tistools/path_weights.py b/inftools/tistools/path_weights.py index a5d33bb..b3737c6 100644 --- a/inftools/tistools/path_weights.py +++ b/inftools/tistools/path_weights.py @@ -41,7 +41,7 @@ def get_path_weights( data = data[nskip:] # we only need non-zero paths non_zero_paths = data[:, 3] == "----" - minus_paths = data[:, 3] != "----" + minus_paths = ~non_zero_paths data[data == "----"] = "0.0" D = {}