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

Commit 9532983

Browse files
authored
save_trajs support for fragmented data source (#1514)
* save_trajs support for fragmented data source * update build matrix * use deeptime clustering backend
1 parent 03602c6 commit 9532983

23 files changed

+159
-1150
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- run: conda config --set quiet true
2222
- run: conda install conda-build -c defaults
2323
- run: mkdir workspace
24-
- run: conda build devtools/conda-recipe --python=3.7 --no-test --output-folder workspace
24+
- run: conda build devtools/conda-recipe --python=3.9 --numpy=1.19 --no-test --output-folder workspace
2525
- persist_to_workspace:
2626
root: workspace
2727
paths:
@@ -46,7 +46,7 @@ jobs:
4646
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
4747
- attach_workspace:
4848
at: workspace
49-
- run: conda build devtools/conda-recipe --python=3.7 --test --output-folder workspace
49+
- run: conda build devtools/conda-recipe --python=3.9 --numpy=1.19 --test --output-folder workspace
5050
- run: bash <(curl -s https://codecov.io/bash) -f $HOME/coverage.xml
5151
- store_test_results:
5252
path: /tmp/circleci-test-results

devtools/azure-pipelines-linux.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ jobs:
66

77
strategy:
88
matrix:
9-
Python36:
10-
CONDA_PY: '3.6'
11-
CONDA_NPY: '1.16'
129
Python37:
1310
CONDA_PY: '3.7'
1411
CONDA_NPY: '1.18'
1512
Python38:
1613
CONDA_PY: '3.8'
17-
CONDA_NPY: '1.19'
14+
CONDA_NPY: '1.18'
1815
Python39:
1916
CONDA_PY: '3.9'
2017
CONDA_NPY: '1.19'

devtools/azure-pipelines-osx.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ jobs:
55
vmImage: 'macOS-10.14'
66
strategy:
77
matrix:
8-
Python36:
9-
CONDA_PY: '3.6'
10-
CONDA_NPY: '1.17'
118
Python37:
129
CONDA_PY: '3.7'
13-
CONDA_NPY: '1.19'
10+
CONDA_NPY: '1.18'
11+
Python38:
12+
CONDA_PY: '3.8'
13+
CONDA_NPY: '1.18'
1414
Python39:
1515
CONDA_PY: '3.9'
1616
CONDA_NPY: '1.19'

devtools/azure-pipelines-win.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
matrix:
88
Python37:
99
CONDA_PY: '3.7'
10-
CONDA_NPY: '1.19'
10+
CONDA_NPY: '1.18'
1111
Python38:
1212
CONDA_PY: '3.8'
13-
CONDA_NPY: '1.19'
13+
CONDA_NPY: '1.18'
1414
Python39:
1515
CONDA_PY: '3.9'
1616
CONDA_NPY: '1.19'

devtools/conda-recipe/meta.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ requirements:
3535
- setuptools
3636
- pip
3737
- pybind11
38-
- deeptime
38+
- pybind11-abi
39+
- deeptime >=0.3.0
3940

4041
run:
4142
- bhmm >=0.6.3

pyemma/_base/serialization/tests/test_cli.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,44 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18-
18+
import shutil
1919
import tempfile
20-
import unittest
2120

21+
import pytest
22+
from numpy.testing import assert_
2223

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

2627

27-
class TestListModelCLI(unittest.TestCase):
28-
@classmethod
29-
def setUpClass(cls):
28+
@pytest.fixture
29+
def model_file():
30+
file = None
31+
try:
3032
from pyemma.datasets import get_bpti_test_data
31-
3233
d = get_bpti_test_data()
3334
trajs, top = d['trajs'], d['top']
3435
s = source(trajs, top=top)
3536

3637
t = tica(s, lag=1)
3738

3839
c = cluster_kmeans(t)
39-
cls.model_file = tempfile.mktemp()
40-
c.save(cls.model_file, save_streaming_chain=True)
41-
42-
@classmethod
43-
def tearDownClass(cls):
44-
import os
45-
os.unlink(cls.model_file)
46-
47-
def test_recursive(self):
48-
""" check the whole chain has been printed"""
49-
from pyemma.util.contexts import Capturing
50-
with Capturing() as out:
51-
main(['--recursive', self.model_file])
52-
assert out
53-
all_out = '\n'.join(out)
54-
self.assertIn('FeatureReader', all_out)
55-
self.assertIn('TICA', all_out)
56-
self.assertIn('Kmeans', all_out)
57-
58-
59-
if __name__ == '__main__':
60-
unittest.main()
40+
file = tempfile.mktemp()
41+
c.save(file, save_streaming_chain=True)
42+
43+
yield file
44+
finally:
45+
if file is not None:
46+
shutil.rmtree(file, ignore_errors=True)
47+
48+
49+
def test_recursive(model_file):
50+
""" check the whole chain has been printed"""
51+
from pyemma.util.contexts import Capturing
52+
with Capturing() as out:
53+
main(['--recursive', model_file])
54+
assert out
55+
all_out = '\n'.join(out)
56+
assert_('FeatureReader' in all_out)
57+
assert_('TICA' in all_out)
58+
assert_('Kmeans' in all_out)

pyemma/coordinates/api.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
2222
.. currentmodule:: pyemma.coordinates.api
2323
"""
24+
from pathlib import Path
25+
2426
import numpy as _np
2527
import logging as _logging
2628

@@ -632,7 +634,7 @@ def discretizer(reader,
632634
return disc
633635

634636

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

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

844-
_, fmt = os.path.splitext(traj_inp.filenames[0])
851+
_, fmt = os.path.splitext(fname)
845852
else:
846853
fmt = '.' + fmt
847854

pyemma/coordinates/clustering/include/Clustering.h

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)