Skip to content

Commit

Permalink
numpy2 support, drop py38 (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
clonker authored Jul 16, 2024
1 parent d8596f1 commit f4ae6e4
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 42 deletions.
6 changes: 3 additions & 3 deletions azure-cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ jobs:
- job: linux
pool: { vmImage: 'Ubuntu-22.04' }
variables:
CIBW_BUILD: cp3{8,9,10,11}-manylinux_x86_64
CIBW_BUILD: cp3{9,10,11}-manylinux_x86_64
CIBW_BUILD_VERBOSITY: 2
steps:
- template: devtools/cibuildwheel.yml

- job: macos
pool: { vmImage: 'macOS-12' }
variables:
CIBW_BUILD: cp3{8,9,10,11}-macosx_*
CIBW_BUILD: cp3{9,10,11}-macosx_*
CIBW_ARCHS_MACOS: $(arch)
strategy:
matrix:
Expand All @@ -24,6 +24,6 @@ jobs:
- job: windows
pool: { vmImage: 'windows-2019' }
variables:
CIBW_BUILD: cp3{8,9,10,11}-win_amd64
CIBW_BUILD: cp3{9,10,11}-win_amd64
steps:
- template: devtools/cibuildwheel.yml
2 changes: 1 addition & 1 deletion deeptime/markov/tools/analysis/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def expectation(T, a, mu=None):
>>> a = np.array([1.0, 0.0, 1.0])
>>> m_a = expectation(T, a)
>>> m_a # doctest: +ELLIPSIS
0.909090909...
np.float64(0.909090909...
"""
# check if square matrix and remember size
Expand Down
2 changes: 1 addition & 1 deletion deeptime/markov/tools/analysis/dense/_pcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _pcca_connected(P, n, pi=None):
evecs[:, 0] = np.abs(evecs[:, 0])

# Is there a significant complex component?
if not np.alltrue(np.isreal(evecs)):
if not np.all(np.isreal(evecs)):
warnings.warn(
"The given transition matrix has complex eigenvectors, so it doesn't exactly fulfill detailed balance. "
"Forcing eigenvectors to be real and continuing. Be aware that this is not theoretically solid.")
Expand Down
4 changes: 2 additions & 2 deletions deeptime/markov/tools/estimation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,12 @@ def log_likelihood(C, T):
>>> C = np.array([[58, 7, 0], [6, 0, 4], [0, 3, 21]])
>>> logL = log_likelihood(C, T)
>>> logL # doctest: +ELLIPSIS
-38.2808034725...
np.float64(-38.2808034725...
>>> C = np.array([[58, 20, 0], [6, 0, 4], [0, 3, 21]])
>>> logL = log_likelihood(C, T)
>>> logL # doctest: +ELLIPSIS
-68.2144096814...
np.float64(-68.2144096814...
References
----------
Expand Down
2 changes: 1 addition & 1 deletion deeptime/plots/chapman_kolmogorov.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def plot_ck_test(data: ChapmanKolmogorovTest, height=2.5, aspect=1.,

if any_complex:
warnings.warn("Your CKtest contains imaginary components which are ignored during plotting.",
category=np.ComplexWarning)
category=np.exceptions.ComplexWarning)

confidences = [confidences_est_l, confidences_est_r, confidences_pred_l, confidences_pred_r]
confidences = [np.array(conf) for conf in confidences]
Expand Down
2 changes: 1 addition & 1 deletion deeptime/plots/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def state_sizes(self, value: Optional[np.ndarray]):
if value is not None and len(value) != self.n_nodes:
raise ValueError(f"State sizes must correspond to states (# = {self.n_nodes}) but was of "
f"length {len(value)}")
self._state_sizes = np.asfarray(value) if value is not None else np.ones(self.n_nodes)
self._state_sizes = np.asarray(value, dtype=float) if value is not None else np.ones(self.n_nodes)

@property
def node_sizes(self):
Expand Down
2 changes: 1 addition & 1 deletion deeptime/util/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def evaluate_samples(samples: Iterable[Any], quantity: str, delimiter: str = '/'
if quantity is not None:
samples = [call_member(s, quantity, *args, **kwargs) for s in samples]
try:
samples = np.asfarray(samples)
samples = np.asarray(samples, dtype=float)
except:
pass
return samples
Expand Down
4 changes: 1 addition & 3 deletions devtools/azure-pipelines-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ jobs:

- job: 'MacOS_with_conda'
pool:
vmImage: 'macOS-latest'
vmImage: 'macOS-12'
steps:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
- bash: sudo chown -R $USER $CONDA
displayName: Take ownership of conda installation
- bash: conda install --yes --quiet libarchive sqlite -n base -c conda-forge
displayName: Fix missing sqlite and libarchive error
- template: checkout.yml
- template: conda-setup+build.yml

Expand Down
2 changes: 0 additions & 2 deletions devtools/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ jobs:

strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
Expand Down
2 changes: 0 additions & 2 deletions devtools/azure-pipelines-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:

strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
Expand Down
2 changes: 0 additions & 2 deletions devtools/azure-pipelines-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ jobs:

strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-setup+build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ steps:
displayName: 'Update and install dependencies'
continueOnError: false
- bash: |
conda build devtools --python 3.11 --numpy 1.21
conda build devtools --python 3.11 --numpy 2.0.0
displayName: 'Build and test'
continueOnError: false
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filter(self, record: LogRecord) -> int:
'sphinxcontrib.katex',
'nbsphinx',
'sphinx_gallery.gen_gallery',
'sphinx_gallery.load_style'
#'sphinx_gallery.load_style'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ authors = [
]
requires-python = ">= 3.8"
dependencies = [
'numpy>=1.20',
'numpy',
'scipy>=1.9.0',
'scikit-learn>=1.2.2',
'scikit-learn>=1.5.0',
'threadpoolctl>=3.1.0'
]
dynamic = ['version']
Expand All @@ -40,13 +40,13 @@ deep-learning = ['torch']
plotting = ['matplotlib', 'networkx']
units = ['pint>=0.20']
tests = [
'torch>=1.12.0; platform_system!="Darwin" and python_version<"3.11"',
'pytest==7.1.2',
'pytest-cov==3.0.0',
'torch>=1.12.0; platform_system!="Darwin" and platform_system!="Windows"',
'pytest>=7.1.2',
'pytest-cov>=3.0.0',
'coverage[toml]',
'pytest-xdist==2.5.0',
'flaky==3.7.0',
'tqdm==4.64.0',
'pytest-xdist>=2.5.0',
'flaky>=3.7.0',
'tqdm>=4.64.0',
"cython>=0.29.30",
"pybind11>=2.10.1",
"networkx",
Expand Down Expand Up @@ -77,10 +77,10 @@ requires = [
"scikit-build>=0.16",
"cython>=0.29.30",
"pybind11>=2.10.1",
"numpy>=1.20",
"numpy",
"cmake>=3.24",
"tomli; python_version < '3.11'",
"scipy==1.9.3",
"scipy>=1.9.3",
"ninja; platform_system!='Windows'",
"versioneer[toml]==0.28"
]
Expand Down
8 changes: 4 additions & 4 deletions tests/markov/test_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_onetraj():
assert (len(res) == len(expected))
for i in range(len(res)):
assert (res[i].shape == expected[i].shape)
assert (np.alltrue(res[i] == expected[i]))
assert (np.all(res[i] == expected[i]))


def test_onetraj_sub():
Expand All @@ -46,7 +46,7 @@ def test_onetraj_sub():
assert (len(res) == len(expected))
for i in range(len(res)):
assert (res[i].shape == expected[i].shape)
assert (np.alltrue(res[i] == expected[i]))
assert (np.all(res[i] == expected[i]))


def test_twotraj():
Expand All @@ -58,15 +58,15 @@ def test_twotraj():
assert (len(res) == len(expected))
for i in range(len(res)):
assert (res[i].shape == expected[i].shape)
assert (np.alltrue(res[i] == expected[i]))
assert (np.all(res[i] == expected[i]))


def test_sample_by_sequence():
dtraj = [0, 1, 2, 3, 2, 1, 0]
idx = sample.compute_index_states(dtraj)
seq = [0, 1, 1, 1, 0, 0, 0, 0, 1, 1]
sidx = sample.indices_by_sequence(idx, seq)
assert (np.alltrue(sidx.shape == (len(seq), 2)))
assert (np.all(sidx.shape == (len(seq), 2)))
for t in range(sidx.shape[0]):
assert (sidx[t, 0] == 0) # did we pick the right traj?
assert (dtraj[sidx[t, 1]] == seq[t]) # did we pick the right states?
Expand Down
12 changes: 6 additions & 6 deletions tests/markov/tools/analysis/impl/dense/pcca_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ def test_pcca_large(self):
P = np.loadtxt(os.path.split(__file__)[0] + '/../../P_rev_251x251.dat')
# n=2
chi = pcca(P, 2)
assert (np.alltrue(chi >= 0))
assert (np.alltrue(chi <= 1))
assert (np.all(chi >= 0))
assert (np.all(chi <= 1))
# n=3
chi = pcca(P, 3)
assert (np.alltrue(chi >= 0))
assert (np.alltrue(chi <= 1))
assert (np.all(chi >= 0))
assert (np.all(chi <= 1))
# n=4
chi = pcca(P, 4)
assert (np.alltrue(chi >= 0))
assert (np.alltrue(chi <= 1))
assert (np.all(chi >= 0))
assert (np.all(chi <= 1))

def test_pcca_coarsegrain(self):
# fine-grained transition matrix
Expand Down
2 changes: 1 addition & 1 deletion tests/plots/test_ck_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_sanity_vamp(fractional):

if fractional:
with warnings.catch_warnings():
warnings.simplefilter("ignore", np.ComplexWarning)
warnings.simplefilter("ignore", np.exceptions.ComplexWarning)
plot_ck_test(models[0].ck_test(models))
else:
plot_ck_test(models[0].ck_test(models))

0 comments on commit f4ae6e4

Please sign in to comment.