From 0e59a002a7b736477150f0f4a7fefa1ff037a25a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 28 Oct 2023 21:03:46 +0100 Subject: [PATCH 01/11] run ci on 3.12 too --- .github/workflows/publish.yml | 2 +- .github/workflows/tests.yml | 2 +- pyproject.toml | 3 ++- tox.ini | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f00c2f8..3225fec 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -120,7 +120,7 @@ jobs: release: name: Pulish to PyPI if upload to Test PyPI was successful runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" + if: startsWith(github.ref, 'refs/tags/') needs: [linux, windows, macos, sdist, release-test] steps: - name: Publish to PyPI diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 613e23d..f977a7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: platform: [ubuntu-latest, macos-latest] - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] steps: diff --git a/pyproject.toml b/pyproject.toml index 474e21d..c0cfb3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ classifiers = [ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.11', "Programming Language :: Rust", 'Topic :: Scientific/Engineering' ] @@ -212,7 +213,7 @@ exclude = ''' ) ''' line-length = 110 -target-version = ["py310", "py311"] +target-version = ["py310", "py311", "py312"] [tool.ruff.isort] force-single-line = false diff --git a/tox.ini b/tox.ini index 243ea14..fe49d5f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,12 @@ [tox] -envlist = py{310,311}-{linux,macos,windows} +envlist = py{310,311,312}-{linux,macos,windows} isolated_build = true [gh-actions] python = 3.10: py310 3.11: py311 + 3.12: py312 fail_on_no_env = true [testenv] From 5b7ea598f8f062b65f2148c1390012be43083bbb Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 31 May 2024 21:39:04 +0100 Subject: [PATCH 02/11] Add setuptools as a dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7c25fa4..72b68ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ dependencies = [ "tidynamics", "seaborn", "tqdm", + "setuptools", # for pkg_resources module in Python 3.12 ] urls.bugtracker = "https://github.com/p-j-smith/lipyphilic/issues" urls.documentation = "https://lipyphilic.readthedocs.io/en/stable" From f2dc3a4cc1302b00254b1fcadb8d65645dd1fae2 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 31 May 2024 21:41:10 +0100 Subject: [PATCH 03/11] Add networkx as a dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 72b68ed..f9292f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dependencies = [ "attrs", "numpy", "scipy", + "networkx", "pandas", "matplotlib", "mdanalysis", From f3e8da09eb1fd3a91b4d2a087afc2630347b7a04 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 31 May 2024 21:52:09 +0100 Subject: [PATCH 04/11] Add MDAnalysisTests as a test dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f9292f7..3d14a0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ tests = [ "pytest-cov", "coverage", "tox", + "MDAnalysisTests", ] docs = [ "sphinx", From b826e09b5ef638122006b042ac7264498df7ee4c Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 31 May 2024 22:26:51 +0100 Subject: [PATCH 05/11] check error with ProjectionPlot.interpolate test --- tests/lipyphilic/plotting/test_plotting.py | 62 +++++++++++++++++----- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/tests/lipyphilic/plotting/test_plotting.py b/tests/lipyphilic/plotting/test_plotting.py index a8441b7..72921c6 100644 --- a/tests/lipyphilic/plotting/test_plotting.py +++ b/tests/lipyphilic/plotting/test_plotting.py @@ -65,19 +65,57 @@ def test_interpolate(self, projection): ], ) - projection.interpolate(method="linear") - - reference = { - "statistic": np.array( - [ - [1, 0.0, 0.5], - [1, 1, 1], - [1, 0.0, 0.5], - ], - ), - } + #projection.interpolate(method="linear") + + statistic_nbins_x, statistic_nbins_y = projection.statistic.shape + statistic = np.tile(projection.statistic, reps=(3, 3)) + + # this snippet is taken from: https://stackoverflow.com/a/37882746 + x, y = np.indices(statistic.shape) + + statistic[np.isnan(statistic)] = scipy.interpolate.griddata( + (x[~np.isnan(statistic)], y[~np.isnan(statistic)]), # points we know + statistic[~np.isnan(statistic)], # values we know + (x[np.isnan(statistic)], y[np.isnan(statistic)]), # points to interpolate + method="linear", + fill_value=np.NaN, + ) + + # reference = { + # "statistic": np.array( + # [ + # [1, 0.0, 0.5], + # [1, 1, 1], + # [1, 0.0, 0.5], + # ], + # ), + # } + + expected = np.array([ + [ np.nan, 0. , 0. , 0. , 0. , 0. , 0. , 0. , np.nan], + [1. , 0. , 1. , 1. , 0. , 1. , 1. , 1. , 1. ], + [1. , 0. , 0.75, 1. , 0. , 0.75, 1. , 0. , 1. ], + [1. , 0. , 0.5 , 1. , 0. , 0.5 , 1. , 0. , 1. ], + [1. , 1. , 1. , 1. , 1. , 1. , 1. , 0. , 1. ], + [1. , 0. , 0.5 , 1. , 0. , 0.5 , 0.25, 0. , 1. ], + [1. , 0. , 0.75, 1. , 0. , 0. , 0. , 0. , 1. ], + [1. , 0. , 1. , 1. , 1. , 1. , 1. , 1. , 1. ], + [ np.nan, 0. , 0. , 0. , 0. , 0. , 0. , 0. , np.nan], + ]) + + assert_array_almost_equal(statistic, expected) + + statistic = statistic[ + statistic_nbins_x : statistic_nbins_x * 2, + statistic_nbins_y : statistic_nbins_y * 2, + ] + expected = expected[ + statistic_nbins_x : statistic_nbins_x * 2, + statistic_nbins_y : statistic_nbins_y * 2, + ] + + assert_array_almost_equal(statistic, expected) - assert_array_almost_equal(projection.statistic, reference["statistic"]) def test_interpolate_no_tile(self, projection): projection.statistic = np.array( From 3a6156f5565370d0a62bba138bc215f8f3c67ae2 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 31 May 2024 22:46:11 +0100 Subject: [PATCH 06/11] simplify test for projection plot interpolate --- tests/lipyphilic/plotting/test_plotting.py | 71 ++++++---------------- 1 file changed, 18 insertions(+), 53 deletions(-) diff --git a/tests/lipyphilic/plotting/test_plotting.py b/tests/lipyphilic/plotting/test_plotting.py index 72921c6..4c5ce82 100644 --- a/tests/lipyphilic/plotting/test_plotting.py +++ b/tests/lipyphilic/plotting/test_plotting.py @@ -59,62 +59,27 @@ def test_project_values(self, projection): def test_interpolate(self, projection): projection.statistic = np.array( [ - [np.NaN, 0, np.NaN], - [1, np.NaN, 1], - [np.NaN, 0, np.NaN], + [1, 1, 1, 1, 1], + [1, np.NaN, 0, np.NaN, 1], + [1, np.NaN, np.NaN, np.NaN, 1], + [1, np.NaN, 0, np.NaN, 1], + [1, 1, 1, 1, 1], ], ) - #projection.interpolate(method="linear") - - statistic_nbins_x, statistic_nbins_y = projection.statistic.shape - statistic = np.tile(projection.statistic, reps=(3, 3)) - - # this snippet is taken from: https://stackoverflow.com/a/37882746 - x, y = np.indices(statistic.shape) - - statistic[np.isnan(statistic)] = scipy.interpolate.griddata( - (x[~np.isnan(statistic)], y[~np.isnan(statistic)]), # points we know - statistic[~np.isnan(statistic)], # values we know - (x[np.isnan(statistic)], y[np.isnan(statistic)]), # points to interpolate - method="linear", - fill_value=np.NaN, - ) - - # reference = { - # "statistic": np.array( - # [ - # [1, 0.0, 0.5], - # [1, 1, 1], - # [1, 0.0, 0.5], - # ], - # ), - # } - - expected = np.array([ - [ np.nan, 0. , 0. , 0. , 0. , 0. , 0. , 0. , np.nan], - [1. , 0. , 1. , 1. , 0. , 1. , 1. , 1. , 1. ], - [1. , 0. , 0.75, 1. , 0. , 0.75, 1. , 0. , 1. ], - [1. , 0. , 0.5 , 1. , 0. , 0.5 , 1. , 0. , 1. ], - [1. , 1. , 1. , 1. , 1. , 1. , 1. , 0. , 1. ], - [1. , 0. , 0.5 , 1. , 0. , 0.5 , 0.25, 0. , 1. ], - [1. , 0. , 0.75, 1. , 0. , 0. , 0. , 0. , 1. ], - [1. , 0. , 1. , 1. , 1. , 1. , 1. , 1. , 1. ], - [ np.nan, 0. , 0. , 0. , 0. , 0. , 0. , 0. , np.nan], - ]) - - assert_array_almost_equal(statistic, expected) - - statistic = statistic[ - statistic_nbins_x : statistic_nbins_x * 2, - statistic_nbins_y : statistic_nbins_y * 2, - ] - expected = expected[ - statistic_nbins_x : statistic_nbins_x * 2, - statistic_nbins_y : statistic_nbins_y * 2, - ] - - assert_array_almost_equal(statistic, expected) + projection.interpolate(method="linear") + + expected = np.array( + [ + [1.0, 1.0, 1.0, 1.0, 1.0], + [1.0, 0.5, 0.0, 0.5, 1.0], + [1.0, 0.5, 0.0, 0.5, 1.0], + [1.0, 0.5, 0.0, 0.5, 1.0], + [1.0, 1.0, 1.0, 1.0, 1.0], + ], + ) + + assert_array_almost_equal(projection.statistic, expected) def test_interpolate_no_tile(self, projection): From a7af7c1b3756bc5c0fe89393442d38ec1e837d57 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 5 Dec 2024 12:59:41 +0000 Subject: [PATCH 07/11] Add 3.12 to list of supported versions --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3d14a0e..ab3f581 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', "Programming Language :: Rust", 'Topic :: Scientific/Engineering' ] From 123304be42f955edc49a3d5fee583f6bb83489a7 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 5 Dec 2024 13:27:12 +0000 Subject: [PATCH 08/11] remove black as we're using ruff --- .pre-commit-config.yaml | 4 ---- pyproject.toml | 23 ----------------------- 2 files changed, 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 816d4d6..48a616a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,3 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - - repo: https://github.com/psf/black - rev: 23.1.0 - hooks: - - id: black diff --git a/pyproject.toml b/pyproject.toml index ab3f581..31055b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -196,29 +196,6 @@ pep8-naming.classmethod-decorators = [ "A001", # Variable 'copyright' shadows a Python builtin ] -[tool.black] -exclude = ''' -( - /( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | \.pytest_cache - | \.ruff_cache - | \.gitignore - | _build - | build - | dist - | examples - )/ -) -''' -line-length = 110 -target-version = ["py310", "py311", "py312"] - [tool.ruff.isort] force-single-line = false combine-as-imports = true From 2aab8b32e2e482ccac384ce436b0e695464eb542 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 5 Dec 2024 13:27:35 +0000 Subject: [PATCH 09/11] pin numpy to < 2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31055b6..8ddb7af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ classifiers = [ ] dependencies = [ "attrs", - "numpy", + "numpy<2", "scipy", "networkx", "pandas", From c0c0963f2c0729115b6cedec22cc7c5eb8c7bb6a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 5 Dec 2024 13:27:58 +0000 Subject: [PATCH 10/11] make linters happy --- tests/lipyphilic/plotting/test_plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lipyphilic/plotting/test_plotting.py b/tests/lipyphilic/plotting/test_plotting.py index 4c5ce82..785ed62 100644 --- a/tests/lipyphilic/plotting/test_plotting.py +++ b/tests/lipyphilic/plotting/test_plotting.py @@ -78,7 +78,7 @@ def test_interpolate(self, projection): [1.0, 1.0, 1.0, 1.0, 1.0], ], ) - + assert_array_almost_equal(projection.statistic, expected) From 4b4016490ef8db5d6eeb0d852d683a625fcdb742 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 5 Dec 2024 14:13:53 +0000 Subject: [PATCH 11/11] Use codecov token for uploading coverage report --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f977a7e..4d1f9c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,8 +38,9 @@ jobs: # Using Codecov's action, upload the coverage report for the triggering commit/PR - name: Upload coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: files: coverage.xml fail_ci_if_error: true verbose: true + token: ${{ secrets.CODECOV_TOKEN }}