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

Commit

Permalink
save_trajs support for fragmented data source (#1514)
Browse files Browse the repository at this point in the history
* save_trajs support for fragmented data source

* update build matrix

* use deeptime clustering backend
  • Loading branch information
clonker committed Nov 2, 2021
1 parent 03602c6 commit 9532983
Show file tree
Hide file tree
Showing 23 changed files with 159 additions and 1,150 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -21,7 +21,7 @@ jobs:
- run: conda config --set quiet true
- run: conda install conda-build -c defaults
- run: mkdir workspace
- run: conda build devtools/conda-recipe --python=3.7 --no-test --output-folder workspace
- run: conda build devtools/conda-recipe --python=3.9 --numpy=1.19 --no-test --output-folder workspace
- persist_to_workspace:
root: workspace
paths:
Expand All @@ -46,7 +46,7 @@ jobs:
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- attach_workspace:
at: workspace
- run: conda build devtools/conda-recipe --python=3.7 --test --output-folder workspace
- run: conda build devtools/conda-recipe --python=3.9 --numpy=1.19 --test --output-folder workspace
- run: bash <(curl -s https://codecov.io/bash) -f $HOME/coverage.xml
- store_test_results:
path: /tmp/circleci-test-results
Expand Down
5 changes: 1 addition & 4 deletions devtools/azure-pipelines-linux.yml
Expand Up @@ -6,15 +6,12 @@ jobs:

strategy:
matrix:
Python36:
CONDA_PY: '3.6'
CONDA_NPY: '1.16'
Python37:
CONDA_PY: '3.7'
CONDA_NPY: '1.18'
Python38:
CONDA_PY: '3.8'
CONDA_NPY: '1.19'
CONDA_NPY: '1.18'
Python39:
CONDA_PY: '3.9'
CONDA_NPY: '1.19'
Expand Down
8 changes: 4 additions & 4 deletions devtools/azure-pipelines-osx.yml
Expand Up @@ -5,12 +5,12 @@ jobs:
vmImage: 'macOS-10.14'
strategy:
matrix:
Python36:
CONDA_PY: '3.6'
CONDA_NPY: '1.17'
Python37:
CONDA_PY: '3.7'
CONDA_NPY: '1.19'
CONDA_NPY: '1.18'
Python38:
CONDA_PY: '3.8'
CONDA_NPY: '1.18'
Python39:
CONDA_PY: '3.9'
CONDA_NPY: '1.19'
Expand Down
4 changes: 2 additions & 2 deletions devtools/azure-pipelines-win.yml
Expand Up @@ -7,10 +7,10 @@ jobs:
matrix:
Python37:
CONDA_PY: '3.7'
CONDA_NPY: '1.19'
CONDA_NPY: '1.18'
Python38:
CONDA_PY: '3.8'
CONDA_NPY: '1.19'
CONDA_NPY: '1.18'
Python39:
CONDA_PY: '3.9'
CONDA_NPY: '1.19'
Expand Down
3 changes: 2 additions & 1 deletion devtools/conda-recipe/meta.yaml
Expand Up @@ -35,7 +35,8 @@ requirements:
- setuptools
- pip
- pybind11
- deeptime
- pybind11-abi
- deeptime >=0.3.0

run:
- bhmm >=0.6.3
Expand Down
54 changes: 26 additions & 28 deletions pyemma/_base/serialization/tests/test_cli.py
Expand Up @@ -15,46 +15,44 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import shutil
import tempfile
import unittest

import pytest
from numpy.testing import assert_

from pyemma._base.serialization.cli import main
from pyemma.coordinates import source, tica, cluster_kmeans


class TestListModelCLI(unittest.TestCase):
@classmethod
def setUpClass(cls):
@pytest.fixture
def model_file():
file = None
try:
from pyemma.datasets import get_bpti_test_data

d = get_bpti_test_data()
trajs, top = d['trajs'], d['top']
s = source(trajs, top=top)

t = tica(s, lag=1)

c = cluster_kmeans(t)
cls.model_file = tempfile.mktemp()
c.save(cls.model_file, save_streaming_chain=True)

@classmethod
def tearDownClass(cls):
import os
os.unlink(cls.model_file)

def test_recursive(self):
""" check the whole chain has been printed"""
from pyemma.util.contexts import Capturing
with Capturing() as out:
main(['--recursive', self.model_file])
assert out
all_out = '\n'.join(out)
self.assertIn('FeatureReader', all_out)
self.assertIn('TICA', all_out)
self.assertIn('Kmeans', all_out)


if __name__ == '__main__':
unittest.main()
file = tempfile.mktemp()
c.save(file, save_streaming_chain=True)

yield file
finally:
if file is not None:
shutil.rmtree(file, ignore_errors=True)


def test_recursive(model_file):
""" check the whole chain has been printed"""
from pyemma.util.contexts import Capturing
with Capturing() as out:
main(['--recursive', model_file])
assert out
all_out = '\n'.join(out)
assert_('FeatureReader' in all_out)
assert_('TICA' in all_out)
assert_('Kmeans' in all_out)
11 changes: 9 additions & 2 deletions pyemma/coordinates/api.py
Expand Up @@ -21,6 +21,8 @@
.. currentmodule:: pyemma.coordinates.api
"""
from pathlib import Path

import numpy as _np
import logging as _logging

Expand Down Expand Up @@ -632,7 +634,7 @@ def discretizer(reader,
return disc


def save_traj(traj_inp, indexes, outfile, top=None, stride = 1, chunksize=None, image_molecules=False, verbose=True):
def save_traj(traj_inp, indexes, outfile, top=None, stride=1, chunksize=None, image_molecules=False, verbose=True):
r""" Saves a sequence of frames as a single trajectory.
Extracts the specified sequence of time/trajectory indexes from traj_inp
Expand Down Expand Up @@ -753,6 +755,8 @@ def save_traj(traj_inp, indexes, outfile, top=None, stride = 1, chunksize=None,
return traj
# or to disk as a molecular trajectory file
else:
if isinstance(outfile, Path):
outfile = str(outfile.resolve())
traj.save(outfile)
if verbose:
_logger.info("Created file %s" % outfile)
Expand Down Expand Up @@ -839,9 +843,12 @@ def save_trajs(traj_inp, indexes, prefix='set_', fmt=None, outfiles=None,

# Determine output format of the molecular trajectory file
if fmt is None:
fname = traj_inp.filenames[0]
while hasattr(fname, '__getitem__') and not isinstance(fname, (str, bytes)):
fname = fname[0]
import os

_, fmt = os.path.splitext(traj_inp.filenames[0])
_, fmt = os.path.splitext(fname)
else:
fmt = '.' + fmt

Expand Down
78 changes: 0 additions & 78 deletions pyemma/coordinates/clustering/include/Clustering.h

This file was deleted.

0 comments on commit 9532983

Please sign in to comment.