Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1397 from marscher/vamp_fix_varcut_cutoff
Browse files Browse the repository at this point in the history
Vamp fix varcut cutoff
  • Loading branch information
marscher authored Feb 12, 2019
2 parents 58a5345 + 508d925 commit a80be72
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 19 deletions.
10 changes: 2 additions & 8 deletions devtools/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ build:
- CIRCLE_TEST_REPORTS
- OMP_NUM_THREADS
- PYEMMA_NJOBS
script: python setup.py install --single-version-externally-managed --record record.txt
# workaround for bpo-24935, the compiler jinja2 template sets CC, but LDSHARED is not being set accordingly by distutils.sysconfig.
script: LDSHARED="$CC -shared" python setup.py install --single-version-externally-managed --record record.txt # [linux]
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv"

requirements:
build:
Expand All @@ -34,8 +32,7 @@ requirements:
- python
- scipy
- setuptools
# use build flags (eg. CFLAGS etc) from conda-forge
#- toolchain
- pip
- pybind11

run:
Expand All @@ -45,7 +42,6 @@ requirements:
- intel-openmp # [osx]
- matplotlib
- mdtraj >=1.8
- mock # TODO: remove when py3k only.
- msmtools >=1.2
- {{ pin_compatible('numpy') }}
- pathos
Expand All @@ -54,9 +50,7 @@ requirements:
- pyyaml
- scipy
- setuptools
- six >=1.10
- tqdm
- progress_reporter >=2

test:
source_files:
Expand Down
3 changes: 2 additions & 1 deletion doc/source/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
2.5.5 (??-??-????)
------------------

This version only supports Python 3.
For now all future versions will only support Python 3. :pr:`1395`

**New features**:

Expand All @@ -23,6 +23,7 @@ This version only supports Python 3.
- coordinates: VAMP: changed default projection vector from right to left, since only the left singular functions induce
a kinetic map wrt. the conventional forward propagator, while the right singular functions induce
a kinetic map wrt. the backward propagator. :pr:`1394`
- coordinates: VAMP: fixed variance cutoff to really include as many dimensions to meet subspace variance criterion. :pr:`1397`


**Contributors**:
Expand Down
2 changes: 1 addition & 1 deletion pyemma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _version_check(current, testing=False):
Can be disabled by setting config.check_version = False.
>>> from mock import patch
>>> from unittest.mock import patch
>>> import warnings, pyemma
>>> with warnings.catch_warnings(record=True) as cw, patch('pyemma.version', '0.1'):
... warnings.simplefilter('always', UserWarning)
Expand Down
3 changes: 1 addition & 2 deletions pyemma/_base/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ def estimate_param_scan(estimator, X, param_sets, evaluate=None, evaluate_args=N
if logger_available:
logger = estimators[0].logger
if progress_reporter is None:
from mock import MagicMock
# TODO: replace with nullcontext from util once merged
from unittest.mock import MagicMock
ctx = progress_reporter = MagicMock()
callback = None
else:
Expand Down
2 changes: 1 addition & 1 deletion pyemma/coordinates/clustering/tests/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import unittest
from contextlib import contextmanager

from mock import patch
from unittest.mock import patch
from pyemma.util.files import TemporaryDirectory
from logging import getLogger

Expand Down
2 changes: 1 addition & 1 deletion pyemma/coordinates/tests/test_random_access_stride.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def test_RA_high_stride(self):
for ext in savable_formats_mdtra_18:
traj = create_traj(length=n, dir=self.tmpdir, format=ext)[0]

from mock import patch
from unittest.mock import patch
# temporarily overwrite the memory cutoff with a smaller value, to trigger the switch to RA stride.
with patch('pyemma.coordinates.util.patches.iterload.MEMORY_CUTOFF', n_bytes - 1):
r = coor.source(traj, top=get_top())
Expand Down
2 changes: 1 addition & 1 deletion pyemma/coordinates/tests/test_traj_info_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import tempfile
import unittest

import mock
from unittest import mock

from pyemma.coordinates import api
from pyemma.coordinates.data.feature_reader import FeatureReader
Expand Down
11 changes: 11 additions & 0 deletions pyemma/coordinates/tests/test_vamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ def test_singular_functions_against_MSM(self):
np.testing.assert_allclose(np.diag(p), np.diag(r), atol=1E-6)
np.testing.assert_allclose(np.abs(p), np.abs(r), atol=1E-6)

cumsum_Tsym = np.cumsum(S[1:] ** 2)
cumsum_Tsym /= cumsum_Tsym[-1]
np.testing.assert_allclose(self.vamp.cumvar, cumsum_Tsym)

def test_cumvar_variance_cutoff(self):
for d in (0.2, 0.5, 0.8, 0.9, 1.0):
self.vamp.dim = d
special_cumvar = np.asarray([0] + self.vamp.cumvar.tolist())
self.assertLessEqual(d, special_cumvar[self.vamp.dimension()],)
self.assertLessEqual(special_cumvar[self.vamp.dimension() - 1], d)

def test_CK_expectation_against_MSM(self):
obs = np.eye(3) # observe every state
cktest = self.vamp.cktest(observables=obs, statistics=None, mlags=4)
Expand Down
2 changes: 1 addition & 1 deletion pyemma/coordinates/transform/vamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _dimension(rank0, rankt, dim, singular_values):
if dim is None or (isinstance(dim, float) and dim == 1.0):
return min(rank0, rankt)
if isinstance(dim, float):
return np.count_nonzero(VAMPModel._cumvar(singular_values) >= dim)
return np.searchsorted(VAMPModel._cumvar(singular_values), dim) + 1
else:
return np.min([rank0, rankt, dim])

Expand Down
2 changes: 1 addition & 1 deletion pyemma/msm/tests/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import unittest
import mock
from unittest import mock
from pyemma import msm
from functools import wraps

Expand Down
2 changes: 1 addition & 1 deletion pyemma/util/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_mute_logging(self):
def test_mute_progress(self):
""" switch mute on shall turn off progress bars"""
from pyemma._base.progress import ProgressReporterMixin
import mock
from unittest import mock
rp = ProgressReporterMixin()

self.config_inst.mute = True
Expand Down
2 changes: 1 addition & 1 deletion pyemma/util/tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from pyemma.util import log
from pyemma.util import config
import mock
from unittest import mock


class TestNonWriteableLogFile(unittest.TestCase):
Expand Down

0 comments on commit a80be72

Please sign in to comment.