Skip to content

Commit 66c10e4

Browse files
authored
minor improvements (#268)
* move azure cibuildwheel main yml to root * print cmake status for version and whether tests are enabled * increase verbosity for cibuildwheel on linux * fix tests: compatibility to numpy 1.24, fixed some deprecation warnings regarding matplotlib and networkx * make test_reversible_pi flaky
1 parent a833ab4 commit 66c10e4

10 files changed

+60
-88
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ endif()
1313
project(deeptime LANGUAGES C CXX VERSION ${DEEPTIME_VERSION})
1414
set(DEEPTIME_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
1515

16+
message(STATUS "Got deeptime version ${DEEPTIME_VERSION}")
17+
message(STATUS "Got deeptime full version ${DEEPTIME_VERSION_INFO}")
18+
message(STATUS "Building tests: ${DEEPTIME_BUILD_CPP_TESTS}")
19+
1620
include(GNUInstallDirs)
1721

1822
if(SKBUILD)

azure-cibuildwheel.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
jobs:
2+
- job: linux
3+
pool: { vmImage: 'Ubuntu-22.04' }
4+
variables:
5+
CIBW_BUILD: cp3{8,9,10,11}-manylinux_x86_64
6+
CIBW_BUILD_VERBOSITY: 2
7+
steps:
8+
- template: devtools/cibuildwheel.yml
9+
10+
- job: macos
11+
pool: { vmImage: 'macOS-12' }
12+
variables:
13+
CIBW_BUILD: cp3{8,9,10,11}-macosx_*
14+
CIBW_ARCHS_MACOS: $(arch)
15+
strategy:
16+
matrix:
17+
x86_64:
18+
arch: 'x86_64'
19+
arm64:
20+
arch: 'arm64'
21+
steps:
22+
- template: devtools/cibuildwheel.yml
23+
24+
- job: windows
25+
pool: { vmImage: 'windows-2019' }
26+
variables:
27+
CIBW_BUILD: cp3{8,9,10,11}-win_amd64
28+
steps:
29+
- template: devtools/cibuildwheel.yml

deeptime/plots/chapman_kolmogorov.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def legend(self, conf=None):
8686
handles.append(self._lpred_handles[ix])
8787
labels.append(predlabel)
8888
labels.append(estlabel)
89-
self.figure.legend(handles, labels, 'upper center', ncol=2, frameon=False)
89+
self.figure.legend(handles, labels, loc='upper center', ncol=2, frameon=False)
9090

9191
@property
9292
def n_tests(self):

deeptime/plots/network.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _draw_arrow(ax, pos_1, pos_2, label="", width=1.0, arrow_curvature=1.0, colo
198198
@property
199199
def edge_base_scale(self):
200200
r""" Base scale for edges depending on the matplotlib default line width and the maximum off-diagonal
201-
element in the adjacency matrix """
201+
element in the adjacency matrix. Returns default line width if all off-diagonal elements are zero. """
202202
if issparse(self.adjacency_matrix):
203203
mat = self.adjacency_matrix.tocoo()
204204
max_off_diag = 0
@@ -209,7 +209,7 @@ def edge_base_scale(self):
209209
diag_mask = np.logical_not(np.eye(self.adjacency_matrix.shape[0], dtype=bool))
210210
max_off_diag = np.max(np.abs(self.adjacency_matrix[diag_mask]))
211211
default_lw = default_line_width()
212-
return 2 * default_lw / max_off_diag
212+
return 2 * default_lw / max_off_diag if max_off_diag > 0 else default_lw
213213

214214
@property
215215
def edge_labels(self) -> Optional[np.ndarray]:
@@ -531,7 +531,7 @@ def plot_markov_model(msm: Union[MarkovStateModel, np.ndarray], pos=None, state_
531531
P[flux < minflux] = 0.0
532532
if pos is None:
533533
import networkx as nx
534-
graph = nx.from_scipy_sparse_matrix(P) if msm.sparse else nx.from_numpy_matrix(P)
534+
graph = nx.from_scipy_sparse_array(P) if msm.sparse else nx.from_numpy_array(P)
535535
pos = nx.spring_layout(graph)
536536
network = Network(P, pos=pos, state_scale=state_scale, state_colors=state_colors, state_labels=state_labels,
537537
state_sizes=state_sizes, edge_scale=edge_scale, edge_curvature=edge_curvature,

devtools/azure-pipelines-cibuildwheel.yml

-78
This file was deleted.

devtools/cibuildwheel.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
steps:
2+
- template: checkout.yml
3+
- task: UsePythonVersion@0
4+
inputs:
5+
versionSpec: '3.10'
6+
architecture: 'x64'
7+
displayName: Use Python 3.10
8+
- bash: |
9+
set -o errexit
10+
python3 -m pip install --upgrade pip
11+
pip3 install cibuildwheel
12+
displayName: Install dependencies
13+
- bash: cibuildwheel --output-dir wheelhouse .
14+
displayName: Build wheels
15+
- task: PublishBuildArtifacts@1
16+
inputs: { pathtoPublish: 'wheelhouse' }

tests/markov/msm/test_tram.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_tram_different_input_data_types(dtrajs, ttrajs, bias_matrix_as_ndarray,
5656

5757

5858
def test_lagtime_too_long():
59-
dtrajs = np.asarray([[0, 1, 0], [0, 1, 2, 1], [2, 3]])
59+
dtrajs = np.asarray([[0, 1, 0], [0, 1, 2, 1], [2, 3]], dtype=object)
6060
bias_matrices = [np.random.rand(len(traj), 3) for traj in dtrajs]
6161
tram = TRAM(maxiter=100, lagtime=2)
6262
with np.testing.assert_raises(ValueError):
@@ -150,7 +150,7 @@ def to_numpy_arrays(dtrajs, bias_matrices, ttrajs):
150150
ttrajs = [np.asarray(traj) for traj in ttrajs]
151151

152152
if not isinstance(bias_matrices, np.ndarray):
153-
bias_matrices = [np.asarray(M) for M in bias_matrices]
153+
bias_matrices = [np.asarray(M, dtype=object) for M in bias_matrices]
154154

155155
return dtrajs, bias_matrices, ttrajs
156156

tests/markov/tools/estimation/impl/dense/tmatrix_sampler_test.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.. moduleauthor:: B.Trendelkamp-Schroer <benjamin DOT trendelkamp-schroer AT fu-berlin DOT de>
44
55
"""
6-
6+
import flaky
77
import numpy as np
88
import pytest
99
from deeptime.markov.tools.estimation import transition_matrix as tmatrix
@@ -60,7 +60,8 @@ def test_reversible(dtype):
6060

6161

6262
@pytest.mark.parametrize("dtype", (np.float32, np.float64, np.longdouble))
63-
def test_reversible_pi(fixed_seed, dtype):
63+
@flaky.flaky(3)
64+
def test_reversible_pi(dtype):
6465
C = np.array([[7048, 6, 0], [6, 2, 3], [0, 3, 2933]]).astype(dtype)
6566
pi = np.array([0.70532947, 0.00109989, 0.29357064])
6667
P_mle = tmatrix(C, reversible=True, mu=pi)

tests/markov/tools/flux/test_reactive_flux.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_coarse_grain(sparse_mode):
198198
Csym = C + C.T
199199
P = Csym / np.sum(Csym, axis=1)[:, np.newaxis]
200200
if sparse_mode:
201-
P = sparse.csr_matrix(P)
201+
P = sparse.lil_matrix(P)
202202
msm = MarkovStateModel(P)
203203
tpt = msm.reactive_flux([0, 4], [11, 15])
204204
coarse_sets = [[2, 3, 6, 7], [10, 11, 14, 15], [0, 1, 4, 5], [8, 9, 12, 13], ]

tests/plots/test_network.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_network(labels, cmap):
2424

2525
flux = MarkovStateModel(Psparse).reactive_flux([2], [3])
2626

27-
positions = nx.planar_layout(nx.from_scipy_sparse_matrix(flux.gross_flux))
27+
positions = nx.planar_layout(nx.from_scipy_sparse_array(flux.gross_flux))
2828
pl = Network(flux.gross_flux, positions, edge_curvature=2., edge_labels=labels,
2929
state_colors=np.linspace(0, 1, num=flux.n_states), cmap=cmap)
3030
ax = pl.plot()

0 commit comments

Comments
 (0)