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 6 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
9 changes: 9 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ The rules for this file:
* release numbers follow "Semantic Versioning" https://semver.org

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

* unreleased

Fixes
- Change the dE method in u_nk2series to use the difference between two
lambda columns (issue #299, PR #300).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more specific what bug was fixed — instead of the word "Change", something like "fixed to now use .... (note: will lead to different results than before) (issue ....)"

If I am a user and look through CHANGES I would want to understand if anything affects me.



12/12/2022 xiki-tempula, orbeckst

* 2.0.0
Expand Down
9 changes: 7 additions & 2 deletions src/alchemlyb/preprocessing/subsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ 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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add "... instead of ..." so that people have an idea what behavior changed


"""

Expand Down Expand Up @@ -196,11 +199,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