def test_statistical_inefficiency(self, dhdl): '''Test if extract_u_nk assign the attr correctly''' dataset = load_benzene() dhdl = extract_dHdl(dataset['data']['Coulomb'][0], 310) new_dhdl = statistical_inefficiency(dhdl) assert new_dhdl.attrs['temperature'] == 310 assert new_dhdl.attrs['energy_unit'] == 'kT'
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 slicer(self, *args, **kwargs): return statistical_inefficiency(*args, **kwargs)
def test_duplication_on_series_noseries(self, gmx_ABFE): duplicated = alchemlyb.concat([gmx_ABFE, gmx_ABFE]) subsample = statistical_inefficiency(duplicated.sum(axis=1), None, drop_duplicates=True) assert len(subsample) == 1001
def test_duplication_on_dataframe(self, gmx_ABFE): duplicated = alchemlyb.concat([gmx_ABFE, gmx_ABFE]) subsample = statistical_inefficiency(duplicated, duplicated.sum(axis=1), drop_duplicates=True) assert len(subsample) < 1000
def test_duplication_off(self, gmx_ABFE): duplicated = alchemlyb.concat([gmx_ABFE, gmx_ABFE]) with pytest.raises(KeyError): statistical_inefficiency(duplicated, duplicated.sum(axis=1), drop_duplicates=False)
def test_sort_on_noseries(self, gmx_ABFE): unsorted = alchemlyb.concat([gmx_ABFE[-500:], gmx_ABFE[:500]]) subsample = statistical_inefficiency(unsorted, None, sort=True) assert subsample.reset_index(0)['time'].is_monotonic_increasing
def test_sort_off(self, gmx_ABFE): unsorted = alchemlyb.concat([gmx_ABFE[-500:], gmx_ABFE[:500]]) with pytest.raises(KeyError): statistical_inefficiency(unsorted, unsorted.sum(axis=1), sort=False)
def test_multiindex_duplicated(self, gmx_ABFE): subsample = statistical_inefficiency(gmx_ABFE, gmx_ABFE.sum(axis=1)) assert len(subsample) == 501