Skip to content

Commit

Permalink
Change order of series vs. data check (#167)
Browse files Browse the repository at this point in the history
* Change order of series vs. data check (fixes #166)

Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
Co-authored-by: Zhiyi Wu <zhiyi.wu@bioch.ox.ac.uk>
  • Loading branch information
3 people authored Sep 23, 2021
1 parent 8c24a3a commit 093ad87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ Chronological list of authors
- Victoria Lim (@vlim)
- Hyungro Lee (@lee212)
- Mohammad S. Barhaghi (@msoroush)

2020
- Zhiyi Wu (@xiki-tempula)
- Zhiyi Wu (@xiki-tempula)

2021
- Alexander Schlaich (@schlaicha)
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The rules for this file:
* release numbers follow "Semantic Versioning" https://semver.org

------------------------------------------------------------------------------
??/??/2021
??/??/2021 schlaicha

* 0.6.0

Expand All @@ -22,6 +22,7 @@ Changes
Enhancements

Fixes
- Subsampling now works with bounds and step (PR #167, issue #166).


09/17/2021 xiki-tempula, orbeckst
Expand Down
5 changes: 3 additions & 2 deletions src/alchemlyb/preprocessing/subsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ def statistical_inefficiency(df, series=None, lower=None, upper=None, step=None,
"values are sorted by time, increasing.")

if series is not None:
series = slicing(series, lower=lower, upper=upper, step=step)


if (len(series) != len(df) or
not all(series.reset_index()['time'] == df.reset_index()['time'])):
raise ValueError("series and data must be sampled at the same times")

series = slicing(series, lower=lower, upper=upper, step=step)

# calculate statistical inefficiency of series (could use fft=True but needs test)
statinef = statisticalInefficiency(series, fast=False)
Expand Down
10 changes: 10 additions & 0 deletions src/alchemlyb/tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ def test_duplicated_exception(self, data):
with pytest.raises(KeyError):
self.slicer(data.sort_index(0), lower=200)

def test_subsample_bounds_and_step(self, gmx_ABFE):
"""Make sure that slicing the series also works
"""
subsample = statistical_inefficiency(gmx_ABFE,
gmx_ABFE.sum(axis=1),
lower=100,
upper=400,
step=2)
assert len(subsample) == 76

def test_multiindex_duplicated(self, gmx_ABFE):
subsample = statistical_inefficiency(gmx_ABFE,
gmx_ABFE.sum(axis=1))
Expand Down

0 comments on commit 093ad87

Please sign in to comment.