From fa373e54f387c6b177b9e1b1db31a91dfb3d249d Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Sat, 18 Oct 2025 19:44:06 -0700 Subject: [PATCH 1/2] use python 3.13 --- .github/workflows/build-ci.yml | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index f5046cf..d383759 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v6 with: - python-version: "3.10" + python-version: "3.13" cache: "pip" cache-dependency-path: pyproject.toml - name: Test pre-commit hooks @@ -36,7 +36,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v6 with: - python-version: "3.10" + python-version: "3.13" cache: "pip" cache-dependency-path: pyproject.toml @@ -49,30 +49,12 @@ jobs: run: | darglint src --strictness=short --ignore-raise=ValueError - tests-jax-latest: + tests: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: "3.10" - cache: "pip" - cache-dependency-path: pyproject.toml + strategy: + matrix: + python-version: ["3.10", "3.13"] - - name: Setup environment - run: | - python -m pip install --upgrade pip - pip install ".[tests,dev]" - - - name: Run Python tests - run: | - pytest --cov=totypes tests - - tests-jax-0_4_31: - runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v5 @@ -80,7 +62,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v6 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} cache: "pip" cache-dependency-path: pyproject.toml @@ -88,7 +70,6 @@ jobs: run: | python -m pip install --upgrade pip pip install ".[tests,dev]" - pip install --upgrade "jax==0.4.31" - name: Run Python tests run: | From abaa55f32f44f5a518cf1f809d1c5cfcf4ee71c0 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Sat, 18 Oct 2025 19:56:29 -0700 Subject: [PATCH 2/2] fix type comparison --- tests/test_types.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/test_types.py b/tests/test_types.py index 73b473c..420010f 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -16,6 +16,11 @@ class BoundedArrayTest(unittest.TestCase): + def assertBoundedArraysEqual(self, a, b): + onp.testing.assert_array_equal(a.array, b.array) + onp.testing.assert_array_equal(a.lower_bound, b.lower_bound) + onp.testing.assert_array_equal(a.upper_bound, b.upper_bound) + @parameterized.expand([[(1, 5, 4, 3)], [(5, 1, 2)]]) def test_lower_bound_shape_validation(self, invalid_bound_shape): with self.assertRaisesRegex( @@ -46,10 +51,19 @@ def test_flatten_unflatten_single_array_jax(self): ) leaves, treedef = jax.tree_util.tree_flatten(ba) restored_ba = jax.tree_util.tree_unflatten(treedef, leaves) - onp.testing.assert_array_equal(ba, restored_ba) + self.assertBoundedArraysEqual(ba, restored_ba) class Density2DArrayTest(unittest.TestCase): + def assertDensitiesEqual(self, a, b): + onp.testing.assert_array_equal(a.array, b.array) + onp.testing.assert_array_equal(a.fixed_solid, b.fixed_solid) + onp.testing.assert_array_equal(a.fixed_void, b.fixed_void) + self.assertEqual(a.minimum_width, b.minimum_width) + self.assertEqual(a.minimum_spacing, b.minimum_spacing) + self.assertEqual(a.periodic, b.periodic) + self.assertEqual(a.symmetries, b.symmetries) + def test_density_ndim_validation(self): with self.assertRaisesRegex(ValueError, "`array` must be at least rank-2,"): types.Density2DArray( @@ -180,7 +194,7 @@ def test_flatten_unflatten_single_density(self): ) leaves, treedef = jax.tree_util.tree_flatten(density) restored_density = jax.tree_util.tree_unflatten(treedef, leaves) - onp.testing.assert_array_equal(density, restored_density) + self.assertDensitiesEqual(density, restored_density) def test_broadcast_fixed_pixels(self): density = types.Density2DArray(