From d404465a62d97b6e98b4803c6c7ebd2e40649e31 Mon Sep 17 00:00:00 2001 From: Marcello Sega Date: Tue, 6 Aug 2024 19:16:55 +0100 Subject: [PATCH] Update requirements, minor fixes * Minor differences in ITIM results due to changes in depedencies * Version bump --- .circleci/config.yml | 6 +++--- .github/workflows/python-package.yml | 6 +++--- pytim/interface.py | 2 +- pytim/itim.py | 14 +++++++------- pytim/observables/contactangle.py | 4 ++-- pytim/utilities.py | 14 ++++++-------- pytim/version.py | 2 +- requirements.txt | 6 +++--- setup.py | 2 +- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e24e5f5c..86cf420b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,7 @@ jobs: # The executor is the environment in which the steps below will be executed - below will use a python 3.8 container # Change the version below to your required version of python docker: - - image: cimg/python:3.8 + - image: cimg/python:3.9 # Checkout the code as the first step. This is a dedicated CircleCI step. # The python orb's install-packages step will install the dependencies from a Pipfile via Pipenv by default. # Here we're making sure we use just use the system-wide pip. By default it uses the project root's requirements.txt. @@ -35,10 +35,10 @@ jobs: # pip-dependency-file: test-requirements.txt # if you have a different name for your requirements file, maybe one that combines your runtime and test requirements. - run: name: Install pytim - command: pip install -r requirements.txt -r requirements.testing.txt -e . + command: pip install --upgrade -r requirements.txt -r requirements.testing.txt -e . - run: name: Run tests - command: python setup.py test + command: pytest pytim/*py pytim/observables/*py pytim/datafiles/*py --doctest-modules # - run: #name: Coverage # # This assumes pytest is installed via the install-package step above diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 00a49e85..6b4a62be 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.11"] + python-version: ["3.9", "3.11"] include: - python-version: "3.9" numpy-version: "1.26.4" @@ -31,7 +31,7 @@ jobs: python -m pip install flake8 pytest python -m pip install mdtraj python -m pip install . - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f requirements.txt ]; then pip install --upgrade -r requirements.txt; fi #- name: Lint with flake8 # run: | # # stop the build if there are Python syntax errors or undefined names @@ -40,5 +40,5 @@ jobs: # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest pytim/*py pytim/observables/*py pytim/datafiles/*py --doctest-modules + pytest pytim/ --doctest-modules diff --git a/pytim/interface.py b/pytim/interface.py index fa169c41..770681f6 100644 --- a/pytim/interface.py +++ b/pytim/interface.py @@ -190,7 +190,7 @@ def _define_cluster_group(self): labels = np.array(labels) # counts is not necessarily ordered by size of cluster. - sorting = np.argsort(counts)[::-1] + sorting = np.argsort(counts,kind='stable')[::-1] # labels for atoms in each cluster starting from the largest unique_labels = np.sort(np.unique(labels[labels > -1])) # by default, all elements of the cluster_group are in diff --git a/pytim/itim.py b/pytim/itim.py index d2535f17..39a83258 100644 --- a/pytim/itim.py +++ b/pytim/itim.py @@ -85,15 +85,15 @@ class ITIM(Interface): >>> print (interface.layers) [[ ] - [ - ]] + [ + ]] >>> interface.layers[0,0] # upper side, first layer >>> interface.layers[1,2] # lower side, third layer - + >>> # or as a whole AtomGroup. This can include all atoms in all layers >>> interface.atoms @@ -170,12 +170,12 @@ def layers(self): >>> print(interface.layers[:,0:3]) # 1st - 3rd layer (0:3), on both sides [[ ] - [ - ]] + [ + ]] >>> print(interface.layers[1,0:4:2]) # side 1, layers 1-4 & stride 2 (0:4:2) - [ ] + [ ] """ @@ -380,7 +380,7 @@ def _assign_layers(self): _y = utilities.get_y(self.cluster_group, self.normal) _z = utilities.get_z(self.cluster_group, self.normal) - sort = np.argsort(_z + _radius * np.sign(_z)) + sort = np.argsort(_z + _radius * np.sign(_z),kind='stable') # NOTE: np.argsort returns the sorted *indices* if self.multiproc and ('win' not in self.system.lower()): diff --git a/pytim/observables/contactangle.py b/pytim/observables/contactangle.py index f7fa0335..0bbbebfb 100644 --- a/pytim/observables/contactangle.py +++ b/pytim/observables/contactangle.py @@ -496,7 +496,7 @@ def _fit_ellipse_fitzgibbon(x, y): C = np.zeros((6, 6), dtype=float) C[0, 2], C[2, 0], C[1, 1] = 2, 2, -1 eigval, eigvec = np.linalg.eig(np.linalg.solve(S, C)) - sort = np.argsort(eigval) + sort = np.argsort(eigval,kind='stable') eigval, eigvec = eigval[sort], eigvec[sort] lam = np.nonzero(np.logical_and( eigval > 0, np.isfinite(eigval)))[0][-1] @@ -515,7 +515,7 @@ def _fit_ellipse_flusser(x, y): C = np.array(((0, 0, 2), (0, -1, 0), (2, 0, 0)), dtype=float) M = np.linalg.solve(C, M) eigval, eigvec = np.linalg.eig(M) - sort = np.argsort(eigval)[::-1] + sort = np.argsort(eigval,kind='stable')[::-1] eigval, eigvec = eigval[sort], eigvec[sort] con = 4 * eigvec[0] * eigvec[2] - eigvec[1]**2 > 0 ak = eigvec[:, np.nonzero(con)[0]] diff --git a/pytim/utilities.py b/pytim/utilities.py index d772b432..57988f1d 100644 --- a/pytim/utilities.py +++ b/pytim/utilities.py @@ -72,17 +72,15 @@ def correlate(a1, a2=None, _normalize=True): ... size.append(len(inter.layers[0,0])) >>> >>> # we need to subtract the average value - >>> np.set_printoptions(precision=3,threshold=1000) + >>> np.set_printoptions(precision=3,threshold=1000,suppress=True) >>> corr = pytim.utilities.correlate(size-np.mean(size)) >>> corr = corr/corr[0] # normalize to 1 >>> print (corr) - [ 1. 0.142 0.104 0.147 0.371 0.099 0.165 0.095 0.338 0.219 - -0.021 0.087 0.245 -0.01 -0.193 0.103 0.029 -0.009 -0.11 0.012 - -0.133 0.056 -0.283 -0.276 0.035 -0.012 -0.211 -0.429 -0.132 -0.263 - 0.072 -0.7 -0.236 0.136 -0.243 -0.878 -0.13 -0.329 -0.386 -0.652 - -0.267 -0.188 -0.226 -0.79 -0.284 -0.02 -1.512 -1.316 -0.188 7.551] - - >>> np.set_printoptions() + [ 1. 0.153 0.104 0.17 0.365 0.115 0.171 0.104 0.342 0.24 + -0.021 0.097 0.265 0.004 -0.169 0.088 0.022 -0.008 -0.113 0.003 + -0.139 0.051 -0.287 -0.279 0.027 -0.019 -0.223 -0.43 -0.157 -0.285 + 0.048 -0.704 -0.26 0.13 -0.31 -0.883 -0.12 -0.323 -0.388 -0.64 + -0.295 -0.177 -0.165 -0.81 -0.321 -0.031 -1.557 -1.296 -0.305 6.974] This will produce (sampling the whole trajectory), the following: diff --git a/pytim/version.py b/pytim/version.py index 1f356cc5..cd7ca498 100644 --- a/pytim/version.py +++ b/pytim/version.py @@ -1 +1 @@ -__version__ = '1.0.0' +__version__ = '1.0.1' diff --git a/requirements.txt b/requirements.txt index df651997..94b5eb6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ cython>=0.24.1 -numpy>=1.16.0 +numpy>=1.26.4,<2.0.0 scipy>=1.6.0 -gsd<=3.2.1 -MDAnalysis>=2.0 +gsd>3.0.0 +MDAnalysis>=2.7.0 PyWavelets>=0.5.2 scikit-image>=0.14.2 sphinx>=1.4.3 diff --git a/setup.py b/setup.py index ba605a2c..44f8aea1 100644 --- a/setup.py +++ b/setup.py @@ -125,7 +125,7 @@ def run_tests(self): # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=[ - 'numpy>=1.16', 'cython>=0.24.1','gsd<=3.2.1' + 'numpy>=1.26.4,<2.0.0', 'cython>=0.24.1','gsd>=3.0.0','MDAnalysis>=2.7.0' ], # List additional groups of dependencies here (e.g. development