Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncorrelation #5

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
python 3 string formatting
dnlbauer committed Aug 2, 2021
commit 3b4cbe920f023a9091b16b85af6f27d8956e9dfb
7 changes: 4 additions & 3 deletions uncorrelate/statistical_inefficiency_dhdl.py
Original file line number Diff line number Diff line change
@@ -54,17 +54,18 @@ def uncorrelate(self, dfs, lower):
dl.append(dli)

uncorrelated_dfs = []
print("Number of correlated and uncorrelated samples (Method=%s):\n\n%6s %12s %12s %12s\n" % ("dHdl", "State", "N", "N_k", "N/N_k"))
print("Number of correlated and uncorrelated samples (Method=dHdl (all)):")
print("\n State N N_k N/N_k\n")
for idx, (dhdl_, l, df) in enumerate(zip(self.dhdls, dl, dfs)):
ind = np.array(l, dtype=bool)
ind = np.array(ind, dtype=int)
dhdl_sum = dhdl_.dot(ind)
uncorrelated_df = alchemlyb.preprocessing.statistical_inefficiency(df, dhdl_sum, lower, conservative=False)
N, N_k = len(df), len(uncorrelated_df)
g = N/N_k
print("%6s %12s %12s %12.2f" % (idx, N, N_k, g))
print(f"{idx:>6} {N:>12} {N_k:>12} {g:>12.2f}")
if N_k < self.uncorr_threshold:
print("WARNING: Only %d uncorrelated samples found at lambda number %d; proceeding with analysis using correlated samples..." % (N_k, idx))
print(f"WARNING: Only {N_k} uncorrelated samples found at lambda number {idx}; proceeding with analysis using correlated samples...")
uncorrelated_dfs.append(df)
else:
uncorrelated_dfs.append(uncorrelated_df)
7 changes: 4 additions & 3 deletions uncorrelate/statistical_inefficiency_dhdl_all.py
Original file line number Diff line number Diff line change
@@ -33,15 +33,16 @@ def uncorrelate(self, dfs, lower):
"""

uncorrelated_dfs = []
print("Number of correlated and uncorrelated samples (Method=%s):\n\n%6s %12s %12s %12s\n" % ("dHdl (all)", "State", "N", "N_k", "N/N_k"))
print("Number of correlated and uncorrelated samples (Method=dHdl (all)):")
print("\n State N N_k N/N_k\n")
for idx, (dhdl_, df) in enumerate(zip(self.dhdls, dfs)):
dhdl_sum = dhdl_.sum(axis=1)
uncorrelated_df = alchemlyb.preprocessing.statistical_inefficiency(df, dhdl_sum, lower, conservative=False)
N, N_k = len(df), len(uncorrelated_df)
g = N/N_k
print("%6s %12s %12s %12.2f" % (idx, N, N_k, g))
print(f"{idx:>6} {N:>12} {N_k:>12} {g:>12.2f}")
if N_k < self.uncorr_threshold:
print("WARNING: Only %d uncorrelated samples found at lambda number %d; proceeding with analysis using correlated samples..." % (N_k, idx))
print(f"WARNING: Only {N_k} uncorrelated samples found at lambda number {idx}; proceeding with analysis using correlated samples...")
uncorrelated_dfs.append(df)
else:
uncorrelated_dfs.append(uncorrelated_df)