Skip to content

Commit d8a705a

Browse files
Fix 337 (#338)
* update * update changes * Fix RTD * fix rtd * update * update --------- Co-authored-by: Oliver Beckstein <[email protected]>
1 parent 99048eb commit d8a705a

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Changes
2626
Enhancements
2727
- Add a TI estimator using gaussian quadrature to calculate the free energy.
2828
(issue #302, PR #304)
29+
- Warning issued when the series is `None` for `statistical_inefficiency`
30+
(issue #337, PR #338)
31+
- ValueError issued when `df` and `series` for `statistical_inefficiency`
32+
doesn't have the same length (issue #337, PR #338)
2933

3034

3135
22/06/2023 xiki-tempula

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dependencies:
1010
- scikit-learn
1111
- pyarrow
1212
- matplotlib
13+
- loguru

readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build:
1313
python: "mambaforge-4.10"
1414

1515
conda:
16-
environment: environment.yml
16+
environment: devtools/conda-envs/test_env.yaml
1717

1818
python:
1919
install:

src/alchemlyb/preprocessing/subsampling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,15 @@ def _prepare_input(df, series, drop_duplicates, sort):
363363
series : Series
364364
Formatted Series.
365365
"""
366+
if series is None:
367+
warnings.warn(
368+
"The series input is `None`, would not subsample according to statistical inefficiency."
369+
)
370+
371+
elif len(df) != len(series):
372+
raise ValueError(
373+
f"The length of df ({len(df)}) should be same as the length of series ({len(series)})."
374+
)
366375
if _check_multiple_times(df):
367376
if drop_duplicates:
368377
df, series = _drop_duplicates(df, series)

src/alchemlyb/tests/test_preprocessing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,3 +544,16 @@ def test_statistical_inefficiency(self, caplog, u_nk):
544544
assert "Running statistical inefficiency analysis." in caplog.text
545545
assert "Statistical inefficiency:" in caplog.text
546546
assert "Number of uncorrelated samples:" in caplog.text
547+
548+
549+
def test_unequil_input(dHdl):
550+
with pytest.raises(ValueError, match="should be same as the length of series"):
551+
statistical_inefficiency(dHdl, series=dHdl[:10])
552+
553+
554+
def test_series_none(dHdl):
555+
with pytest.warns(
556+
UserWarning,
557+
match="The series input is `None`, would not subsample according to statistical inefficiency.",
558+
):
559+
statistical_inefficiency(dHdl, series=None)

0 commit comments

Comments
 (0)