Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiki-tempula committed Dec 24, 2023
1 parent 862343b commit d8f1f24
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ The rules for this file:
Enhancements
- Add a TI estimator using gaussian quadrature to calculate the free energy.
(issue #302, PR #304)
- Warning issued when the series is `None` for `statistical_inefficiency`
(issue #337, PR #304)
- ValueError issued when `df` and `series` for `statistical_inefficiency`
doesn't have the same length (issue #337, PR #304)


22/06/2023 xiki-tempula
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dependencies:
- scikit-learn
- pyarrow
- matplotlib
- loguru
9 changes: 9 additions & 0 deletions src/alchemlyb/preprocessing/subsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ def _prepare_input(df, series, drop_duplicates, sort):
series : Series
Formatted Series.
"""
if series is None:
logger.warning(
"The series input is `None`, would not subsample according to statistical inefficiency."
)

elif len(df) != len(series):
raise ValueError(
f"The length of df ({len(df)}) should be same as the length of series ({len(series)})."
)
if _check_multiple_times(df):
if drop_duplicates:
df, series = _drop_duplicates(df, series)
Expand Down
13 changes: 13 additions & 0 deletions src/alchemlyb/tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,16 @@ def test_statistical_inefficiency(self, caplog, u_nk):
assert "Running statistical inefficiency analysis." in caplog.text
assert "Statistical inefficiency:" in caplog.text
assert "Number of uncorrelated samples:" in caplog.text


def test_unequil_input(dHdl):
with pytest.raises(ValueError, match="should be same as the length of series"):
statistical_inefficiency(dHdl, series=dHdl[:10])


def test_series_none(dHdl, caplog):
statistical_inefficiency(dHdl, series=None)
assert (
"The series input is `None`, would not subsample according to statistical inefficiency."
in caplog.text
)

0 comments on commit d8f1f24

Please sign in to comment.