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 337 #338

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
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)
Loading