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

Fix the dE method for AMBER #300

Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ The rules for this file:
* release numbers follow "Semantic Versioning" https://semver.org

------------------------------------------------------------------------------
*/*/* xiki-tempula,

* unreleased

Fixes
- Fix the dE method in u_nk2series to use the difference between two
lambda columns instead of using the next lambda column or the previous
column for the last window (issue #299, PR #300).


12/12/2022 xiki-tempula, orbeckst

* 2.0.0
Expand Down
10 changes: 8 additions & 2 deletions src/alchemlyb/preprocessing/subsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def u_nk2series(df, method="dE"):


.. versionadded:: 1.0.0
.. versionchanged:: 2.0.1
The `dE` method computes the difference between the current lambda
and the next lambda (previous lambda for the last window), instead
of using the next lambda or the previous lambda for the last window.

"""

Expand Down Expand Up @@ -196,11 +200,13 @@ def u_nk2series(df, method="dE"):
# For the case of more than 1 lambda
index = df.columns.values.tolist().index(key)
# for the state that is not the last state, take the state+1
current_lambda = df.iloc[:, index]
if index + 1 < len(df.columns):
series = df.iloc[:, index + 1]
new_lambda = df.iloc[:, index + 1]
# for the state that is the last state, take the state-1
else:
series = df.iloc[:, index - 1]
new_lambda = df.iloc[:, index - 1]
series = new_lambda - current_lambda
else:
raise ValueError("Decorrelation method {} not found.".format(method))
return series
Expand Down
8 changes: 4 additions & 4 deletions src/alchemlyb/tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def test_decorrelate_u_nk_burnin(u_nk):
remove_burnin=True,
)
)
== 2849
== 2848
)


Expand Down Expand Up @@ -493,9 +493,9 @@ class TestU_nk2series:
@pytest.mark.parametrize(
"methodargs,reference", # reference = sum
[
({}, 9207.80229000283),
({}, 7988.667045),
({"method": "all"}, 85982.34668751864),
({"method": "dE"}, 9207.80229000283),
({"method": "dE"}, 7988.667045),
],
)
def test_u_nk2series(self, u_nk, methodargs, reference):
Expand All @@ -507,7 +507,7 @@ def test_u_nk2series(self, u_nk, methodargs, reference):
"methodargs,reference", # reference = sum
[
({"method": "dhdl_all"}, 85982.34668751864),
({"method": "dhdl"}, 9207.80229000283),
({"method": "dhdl"}, 7988.667045),
],
)
def test_u_nk2series_deprecated(self, u_nk, methodargs, reference):
Expand Down