Skip to content

Commit

Permalink
Fix 337 (#338)
Browse files Browse the repository at this point in the history
* update

* update changes

* Fix RTD

* fix rtd

* update

* update

---------

Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
  • Loading branch information
xiki-tempula and orbeckst authored Jan 3, 2024
1 parent 99048eb commit d8a705a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Changes
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 #338)
- ValueError issued when `df` and `series` for `statistical_inefficiency`
doesn't have the same length (issue #337, PR #338)


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
2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:
python: "mambaforge-4.10"

conda:
environment: environment.yml
environment: devtools/conda-envs/test_env.yaml

python:
install:
Expand Down
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:
warnings.warn(
"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):
with pytest.warns(
UserWarning,
match="The series input is `None`, would not subsample according to statistical inefficiency.",
):
statistical_inefficiency(dHdl, series=None)

0 comments on commit d8a705a

Please sign in to comment.