From 7221ac7f4347d0c76a86db82bac2e848f91a3c9b Mon Sep 17 00:00:00 2001 From: Michael Warner Date: Fri, 9 Oct 2026 14:39:44 -0700 Subject: [PATCH] Add latest Python/JAX/NumPy CI job and bump version to 0.1.1 Add a `latest` job to the Tests workflow that runs on the newest stable Python with the newest JAX and NumPy, ignoring the pins in requirements.txt. Fix the three failures it surfaced: - VariableGroup.add_check read `self.__annotations__`, which instances no longer inherit on Python 3.14 (PEP 649/749); check dataclass fields. - Variable.__getitem__ doctest printed np.True_ under NumPy 2; use np.array_equal, which returns a Python bool. - test_custom_implicit assigned a shape-(1,) array to a scalar element, which NumPy 2.5 rejects; reduce it with np.sum like the second test op. Bump the version to 0.1.1 in csdl_alpha/__init__.py and the Conda recipe, which was still at 0.0.0a2. --- .github/workflows/actions.yml | 24 +++++++++++++++++++ csdl_alpha/__init__.py | 2 +- csdl_alpha/src/graph/variable.py | 2 +- .../custom/tests/test_custom_implicit.py | 2 +- csdl_alpha/src/variable_group.py | 3 ++- recipe/recipe.yaml | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0e5367d..f7c4d7e 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -42,3 +42,27 @@ jobs: - name: Test with pytest run: | pytest + + # Canary run on the newest stable Python with the newest JAX and NumPy, ignoring the pins in requirements.txt + latest: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up latest Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + check-latest: true + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U jax numpy + pip install -e . + python -c "import sys, jax, numpy; print('python', sys.version); print('jax', jax.__version__); print('numpy', numpy.__version__)" + + - name: Test with pytest + run: | + pytest diff --git a/csdl_alpha/__init__.py b/csdl_alpha/__init__.py index e33bfcd..38b2956 100644 --- a/csdl_alpha/__init__.py +++ b/csdl_alpha/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.1.0' +__version__ = '0.1.1' # Standard operations diff --git a/csdl_alpha/src/graph/variable.py b/csdl_alpha/src/graph/variable.py index 9f05ec0..e02c98c 100644 --- a/csdl_alpha/src/graph/variable.py +++ b/csdl_alpha/src/graph/variable.py @@ -321,7 +321,7 @@ def __getitem__(self, indices:Union[Slice, tuple[list[int], int, slice]]) -> 'Va array([[3., 4., 5.]]) >>> x[:].shape (2, 3) - >>> np.all(x[:].value == x.value) + >>> np.array_equal(x[:].value, x.value) True >>> x[1:2,:-1].shape (1, 2) diff --git a/csdl_alpha/src/operations/custom/tests/test_custom_implicit.py b/csdl_alpha/src/operations/custom/tests/test_custom_implicit.py index 067a044..50bf419 100644 --- a/csdl_alpha/src/operations/custom/tests/test_custom_implicit.py +++ b/csdl_alpha/src/operations/custom/tests/test_custom_implicit.py @@ -54,7 +54,7 @@ def compute_jacvec_product(self, inputs, outputs, d_inputs, d_outputs, d_residua # for mode = rev # d_residuals --> d_inputs if mode == 'rev': - d_inputs['a'][1,1] = d_residuals['x']*x_solved**2 + d_residuals['y']*y_solved**2 + d_inputs['a'][1,1] = np.sum(d_residuals['x']*x_solved**2 + d_residuals['y']*y_solved**2) d_inputs['b'] = d_residuals['x']*x_solved + d_residuals['y']*(y_solved+y_solved**2) d_inputs['c'] = d_residuals['x'] + d_residuals['y']/2.0 diff --git a/csdl_alpha/src/variable_group.py b/csdl_alpha/src/variable_group.py index 82e3f73..d2a1b3b 100644 --- a/csdl_alpha/src/variable_group.py +++ b/csdl_alpha/src/variable_group.py @@ -1,4 +1,5 @@ from typing import Union +from dataclasses import fields, is_dataclass import warnings from csdl_alpha.src.graph.variable import Variable from csdl_alpha.utils.inputs import variablize @@ -74,7 +75,7 @@ def add_check(self, name:str, type=None, shape:tuple=None, variablize:bool=False ValueError If parameters for the variable with the given name are already declared. """ - if not name in self.__annotations__: + if not is_dataclass(self) or name not in {field.name for field in fields(self)}: raise ValueError(f"Variable {name} not found in the group.") if name in self._metadata: raise ValueError(f"Checks for variable {name} already declared.") diff --git a/recipe/recipe.yaml b/recipe/recipe.yaml index 58857fa..d92bd42 100644 --- a/recipe/recipe.yaml +++ b/recipe/recipe.yaml @@ -2,7 +2,7 @@ schema_version: 1 package: name: csdl_alpha - version: "0.0.0a2" + version: "0.1.1" source: path: ..