From 74f51628ba22ffc2a2f51ca00c19495adb5612bc Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:27:17 +0100 Subject: [PATCH 1/9] GHA: replace ubuntu-20.04 with ubuntu-latest --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 60851b45b..c2d4bbde1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,7 +13,7 @@ env: jobs: build-python-package: name: Build Python package - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: wheel: ${{ steps.build.outputs.wheel }} steps: @@ -146,7 +146,7 @@ jobs: run: python -um unittest discover -b -q -t . -s examples test-sphinx: name: Test building docs - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 @@ -159,7 +159,7 @@ jobs: build-and-test-container-image: name: Build container image needs: build-python-package - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: # Fixes https://github.com/actions/virtual-environments/issues/3080 STORAGE_OPTS: overlay.mount_program=/usr/bin/fuse-overlayfs From 82d577cd2b920d17b23cf318808119583b20ecd9 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:30:05 +0100 Subject: [PATCH 2/9] GHA: update actions/checkout to v4 --- .github/workflows/release.yml | 2 +- .github/workflows/test.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34e00545f..7494cad3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install dependencies run: python3 -m pip install flit - name: Build package diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c2d4bbde1..54d3c3c41 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,7 +18,7 @@ jobs: wheel: ${{ steps.build.outputs.wheel }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install build dependencies run: python3 -m pip install flit - name: Build package @@ -70,7 +70,7 @@ jobs: NUTILS_TENSORIAL: ${{ matrix.tensorial }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Move nutils directory run: mv nutils _nutils - name: Set up Python ${{ matrix.python-version }} @@ -126,7 +126,7 @@ jobs: PYTHONHASHSEED: 0 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Move nutils directory run: mv nutils _nutils - name: Set up Python @@ -149,7 +149,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install dependencies run: | python3 -um pip install setuptools wheel @@ -166,7 +166,7 @@ jobs: _wheel: ${{ needs.build-python-package.outputs.wheel }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Download Python package artifact uses: actions/download-artifact@v2 with: From dbef86799b982efd90aa0cc3228662a6a3c6003d Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:34:01 +0100 Subject: [PATCH 3/9] GHA: update actions/upload,download-artifact to v4 --- .github/workflows/test.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 54d3c3c41..025056509 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,7 +30,7 @@ jobs: python3 -m flit build echo wheel=`echo dist/*.whl` >> $GITHUB_OUTPUT - name: Upload package artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: python-package path: dist/ @@ -78,7 +78,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Download Python package artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: python-package path: dist/ @@ -132,7 +132,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 - name: Download Python package artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: python-package path: dist/ @@ -168,7 +168,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Download Python package artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: python-package path: dist/ From 71b702d4f39c89bb45c63f45b7c7f1c07fe6ebc7 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:35:31 +0100 Subject: [PATCH 4/9] GHA: update actions/setup-python to v5 --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 025056509..e45bdb9c5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -74,7 +74,7 @@ jobs: - name: Move nutils directory run: mv nutils _nutils - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Download Python package artifact @@ -130,7 +130,7 @@ jobs: - name: Move nutils directory run: mv nutils _nutils - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 - name: Download Python package artifact uses: actions/download-artifact@v4 with: From 30c02751f9f3c172a3cd322766363482af0ea956 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:37:43 +0100 Subject: [PATCH 5/9] GHA: update codecov/codecov-action to v3 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e45bdb9c5..cb60eecf7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -107,7 +107,7 @@ jobs: - name: Post-process coverage run: python -um devtools.gha.coverage_report_xml - name: Upload coverage - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 test-examples: needs: build-python-package name: 'Test examples ${{ matrix.os }}' From a568f09568a01579d0caad1964c8ba457e46cf52 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 12:24:23 +0100 Subject: [PATCH 6/9] GHA: add Python 3.11, 3.12 to test workflow --- .github/workflows/test.yaml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cb60eecf7..f3f403e13 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,20 +42,22 @@ jobs: strategy: matrix: include: - - {name: "baseline", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1} - - {name: "windows", os: windows-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1} - - {name: "macos", os: macos-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1} + - {name: "baseline", os: ubuntu-latest, python-version: "3.12", matrix-backend: numpy, nprocs: 1} + - {name: "windows", os: windows-latest, python-version: "3.12", matrix-backend: numpy, nprocs: 1} + - {name: "macos", os: macos-latest, python-version: "3.12", matrix-backend: numpy, nprocs: 1} - {name: "python 3.7", os: ubuntu-latest, python-version: "3.7", matrix-backend: numpy, nprocs: 1} - {name: "python 3.8", os: ubuntu-latest, python-version: "3.8", matrix-backend: numpy, nprocs: 1} - {name: "python 3.9", os: ubuntu-latest, python-version: "3.9", matrix-backend: numpy, nprocs: 1} - - {name: "scipy matrix", os: ubuntu-latest, python-version: "3.10", matrix-backend: scipy, nprocs: 1} - - {name: "mkl linux", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} - - {name: "mkl linux parallel", os: ubuntu-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 2} - - {name: "mkl windows", os: windows-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} - - {name: "mkl macos", os: macos-latest, python-version: "3.10", matrix-backend: mkl, nprocs: 1} - - {name: "parallel", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 2} + - {name: "python 3.10", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1} + - {name: "python 3.11", os: ubuntu-latest, python-version: "3.11", matrix-backend: numpy, nprocs: 1} + - {name: "scipy matrix", os: ubuntu-latest, python-version: "3.12", matrix-backend: scipy, nprocs: 1} + - {name: "mkl linux", os: ubuntu-latest, python-version: "3.12", matrix-backend: mkl, nprocs: 1} + - {name: "mkl linux parallel", os: ubuntu-latest, python-version: "3.12", matrix-backend: mkl, nprocs: 2} + - {name: "mkl windows", os: windows-latest, python-version: "3.12", matrix-backend: mkl, nprocs: 1} + - {name: "mkl macos", os: macos-latest, python-version: "3.12", matrix-backend: mkl, nprocs: 1} + - {name: "parallel", os: ubuntu-latest, python-version: "3.12", matrix-backend: numpy, nprocs: 2} - {name: "numpy 1.17", os: ubuntu-latest, python-version: "3.7", matrix-backend: numpy, nprocs: 1, numpy-version: ==1.17} - - {name: "tensorial", os: ubuntu-latest, python-version: "3.10", matrix-backend: numpy, nprocs: 1, tensorial: test} + - {name: "tensorial", os: ubuntu-latest, python-version: "3.12", matrix-backend: numpy, nprocs: 1, tensorial: test} fail-fast: false env: _wheel: ${{ needs.build-python-package.outputs.wheel }} @@ -131,6 +133,8 @@ jobs: run: mv nutils _nutils - name: Set up Python uses: actions/setup-python@v5 + with: + python-version: "3.12" - name: Download Python package artifact uses: actions/download-artifact@v4 with: From c6e209bf2563d58062be9ab3e531499df0c8d2a2 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 15:03:19 +0100 Subject: [PATCH 7/9] repl TestCase.assertEquals w/ .assertEqual `unittest.TestCase.assertEquals` has been removed from Python 3.12. --- tests/test_expression_v2.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_expression_v2.py b/tests/test_expression_v2.py index 1832407b0..437170439 100644 --- a/tests/test_expression_v2.py +++ b/tests/test_expression_v2.py @@ -560,28 +560,28 @@ def test_define_for_3d(self): def test_add_single_field(self): ns = expression_v2.Namespace() ns.add_field('u', numpy.array([1,2,3])) - self.assertEquals(ns.u.argshapes, dict(u=(3,))) - self.assertEquals(ns.u.shape, ()) + self.assertEqual(ns.u.argshapes, dict(u=(3,))) + self.assertEqual(ns.u.shape, ()) def test_add_multiple_fields(self): ns = expression_v2.Namespace() ns.add_field(('u', 'v'), numpy.array([1,2,3])) - self.assertEquals(ns.u.argshapes, dict(u=(3,))) - self.assertEquals(ns.u.shape, ()) - self.assertEquals(ns.v.argshapes, dict(v=(3,))) - self.assertEquals(ns.v.shape, ()) + self.assertEqual(ns.u.argshapes, dict(u=(3,))) + self.assertEqual(ns.u.shape, ()) + self.assertEqual(ns.v.argshapes, dict(v=(3,))) + self.assertEqual(ns.v.shape, ()) def test_add_single_field_multiple_bases(self): ns = expression_v2.Namespace() ns.add_field('u', numpy.array([1,2,3]), numpy.array([4,5,6,7])) - self.assertEquals(ns.u.argshapes, dict(u=(3,4))) - self.assertEquals(ns.u.shape, ()) + self.assertEqual(ns.u.argshapes, dict(u=(3,4))) + self.assertEqual(ns.u.shape, ()) def test_add_single_field_with_shape(self): ns = expression_v2.Namespace() ns.add_field('u', numpy.array([1,2,3]), shape=(2,)) - self.assertEquals(ns.u.argshapes, dict(u=(3,2))) - self.assertEquals(ns.u.shape, (2,)) + self.assertEqual(ns.u.argshapes, dict(u=(3,2))) + self.assertEqual(ns.u.shape, (2,)) def test_copy(self): ns1 = expression_v2.Namespace() From 0b6e13efdc8e5095120f7941c80de97cd7b42cd1 Mon Sep 17 00:00:00 2001 From: Joost van Zwieten Date: Tue, 19 Dec 2023 15:08:11 +0100 Subject: [PATCH 8/9] fix invalid escape sequences in strings --- examples/cahnhilliard.py | 2 +- tests/test_function.py | 8 ++++---- tests/test_solver.py | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/cahnhilliard.py b/examples/cahnhilliard.py index ec57c4826..bb1916e2b 100644 --- a/examples/cahnhilliard.py +++ b/examples/cahnhilliard.py @@ -62,7 +62,7 @@ def main(size: Length = parse('10cm'), energy: E(φ) := ∫_Ω ψ(φ) σ / ε + ∫_Ω .5 σ ε ‖∇φ‖² + ∫_Γ (σm + φ σd) - \ \ \ + ╲ ╲ ╲ mixing energy interface energy wall energy Proof: the time derivative of `E` followed by substitution of the strong form diff --git a/tests/test_function.py b/tests/test_function.py index 5c26206bf..c04290a7a 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -24,7 +24,7 @@ def test_cast_invalid_argument(self): function.Array.cast('132') def test_cast_different_shapes(self): - with self.assertRaisesRegex(ValueError, 'cannot convert \[\[1, 2, 3\], \[4, 5\]\] to Array: all input arrays must have the same shape'): + with self.assertRaisesRegex(ValueError, 'cannot convert \\[\\[1, 2, 3\\], \\[4, 5\\]\\] to Array: all input arrays must have the same shape'): function.Array.cast([[1,2,3],[4,5]]) def test_ndim(self): @@ -53,11 +53,11 @@ def test_iter_known(self): self.assertEqual(b.as_evaluable_array.eval(), 2) def test_binop_notimplemented(self): - with self.assertRaisesRegex(TypeError, '^operand type\(s\) all returned NotImplemented from __array_ufunc__'): + with self.assertRaisesRegex(TypeError, '^operand type\\(s\\) all returned NotImplemented from __array_ufunc__'): function.Argument('a', ()) + '1' def test_rbinop_notimplemented(self): - with self.assertRaisesRegex(TypeError, '^operand type\(s\) all returned NotImplemented from __array_ufunc__'): + with self.assertRaisesRegex(TypeError, '^operand type\\(s\\) all returned NotImplemented from __array_ufunc__'): '1' + function.Argument('a', ()) def test_deprecated_simplified(self): @@ -76,7 +76,7 @@ def test_index(self): self.assertEqual(function.Array.cast(2).__index__(), 2) with self.assertRaisesRegex(ValueError, "cannot convert non-constant array to index: arguments=foo"): function.Argument('foo', shape=(), dtype=int).__index__() - with self.assertRaisesRegex(ValueError, "cannot convert non-scalar array to index: shape=\(2,\)"): + with self.assertRaisesRegex(ValueError, "cannot convert non-scalar array to index: shape=\\(2,\\)"): function.Array.cast([2, 3]).__index__() with self.assertRaisesRegex(ValueError, "cannot convert non-integer array to index: dtype=float"): function.Array.cast(2.5).__index__() diff --git a/tests/test_solver.py b/tests/test_solver.py index ce525ffc4..68eb0f6a3 100644 --- a/tests/test_solver.py +++ b/tests/test_solver.py @@ -34,9 +34,9 @@ def _test_recursion_cache(testcase, solver_iter): with testcase.assertLogs('nutils', 'DEBUG') as cm: v = read(length) testcase.assertEqual(v, reference[:length]) - testcase.assertRegex('\n'.join(cm.output), '\[cache\.Recursion [0-9a-f]{40}\] start iterating') - testcase.assertRegex('\n'.join(cm.output), '\[cache\.Recursion [0-9a-f]{40}\.0000\] load' if i and max(lengths[:i]) > 0 - else '\[cache\.Recursion [0-9a-f]{40}\.0000\] cache exhausted') + testcase.assertRegex('\n'.join(cm.output), '\\[cache\\.Recursion [0-9a-f]{40}\\] start iterating') + testcase.assertRegex('\n'.join(cm.output), '\\[cache\\.Recursion [0-9a-f]{40}\\.0000\\] load' if i and max(lengths[:i]) > 0 + else '\\[cache\\.Recursion [0-9a-f]{40}\\.0000\\] cache exhausted') def _test_solve_cache(testcase, solver_gen): @@ -46,10 +46,10 @@ def _test_solve_cache(testcase, solver_gen): with testcase.assertLogs('nutils', 'DEBUG') as cm: v2, info = _edit(solver_gen().solve_withinfo(1e-5)) testcase.assertEqual(v1, v2) - testcase.assertRegex('\n'.join(cm.output), '\[cache\.function [0-9a-f]{40}\] load') + testcase.assertRegex('\n'.join(cm.output), '\\[cache\\.function [0-9a-f]{40}\\] load') with testcase.assertLogs('nutils', 'DEBUG') as cm: solver_gen().solve(1e-6) - testcase.assertRegex('\n'.join(cm.output), '\[cache\.function [0-9a-f]{40}\] failed to load') + testcase.assertRegex('\n'.join(cm.output), '\\[cache\\.function [0-9a-f]{40}\\] failed to load') class laplace(TestCase): From e85c1e84786c569ac6ace80e49df56f036ae8904 Mon Sep 17 00:00:00 2001 From: Gertjan van Zwieten Date: Mon, 29 Jan 2024 12:01:23 +0100 Subject: [PATCH 9/9] fix pyproject version constraints The pyproject.toml contained '~=' version constraints which had the unintended effect of pinning dependencies to specific versions. This patch changes the notation to >=,< combinations. Additionally, the separate (optional) dependency for pillow is removed in favour of requiring matplotlib 3.3, which introduced it as a hard dependency. --- pyproject.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0ce5a3667..90d66d321 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,15 +4,15 @@ readme = "README.md" authors = [ { name = "Evalf", email = "info@evalf.com" }, ] -requires-python = '~=3.7' +requires-python = '>=3.7' dependencies = [ - "appdirs~=1.0", - "bottombar~=2.0.2", - "numpy>=1.17", - "nutils-poly~=1.0", - "psutil~=5.0", + "appdirs >=1,<2", + "bottombar >=2,<3", + "numpy >=1.17,<2", + "nutils-poly >=1,<2", + "psutil >=5,<6", "stringly", - "treelog>=1.0b5", + "treelog >=1,<2", ] dynamic = ["description", "version"] classifiers = [ @@ -22,11 +22,11 @@ classifiers = [ ] [project.optional-dependencies] -docs = ["Sphinx>=1.8"] -export_mpl = ["matplotlib>=1.3", "pillow>2.6"] -matrix_mkl = ["mkl<2024"] -matrix_scipy = ["scipy>=0.13"] -import_gmsh = ["meshio"] +docs = ["Sphinx >=1.8,<8"] +export_mpl = ["matplotlib >=3.3,<4"] +matrix_mkl = ["mkl <2024"] +matrix_scipy = ["scipy >=0.13,<2"] +import_gmsh = ["meshio >=4,<6"] [build-system] requires = ["flit_core >=3.2,<4"]