From 999d30c27a2cead59f2909b1d0c71c54a3ee3c0a Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 9 Nov 2023 15:52:49 +0100 Subject: [PATCH 1/8] Allow Python 3.12 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 79610e64db..30bcc7a932 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "pytensor" dynamic = ['version'] -requires-python = ">=3.9,<3.12" +requires-python = ">=3.9,<3.13" authors = [{ name = "pymc-devs", email = "pymc.devs@gmail.com" }] description = "Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs." readme = "README.rst" From 41906504163fc2b8acac222d42c0873453bbd33b Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 9 Nov 2023 23:47:52 +0100 Subject: [PATCH 2/8] Update Python versions in test workflow --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc0e3f821c..5759ab1ea2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ jobs: if: ${{ needs.changes.outputs.changes == 'true' }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -70,7 +70,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.11"] + python-version: ["3.9", "3.12"] fast-compile: [0,1] float32: [0,1] install-numba: [0] @@ -101,7 +101,7 @@ jobs: float32: 0 part: "tests/link/numba" - install-numba: 1 - python-version: "3.11" + python-version: "3.12" fast-compile: 0 float32: 0 part: "tests/link/numba" @@ -111,7 +111,7 @@ jobs: float32: 0 part: "tests/link/jax" - install-jax: 1 - python-version: "3.11" + python-version: "3.12" fast-compile: 0 float32: 0 part: "tests/link/jax" @@ -249,7 +249,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | From 8828e6ce19eb66629a376c2657b188b18f3b8429 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 9 Nov 2023 23:50:26 +0100 Subject: [PATCH 3/8] Add Python 3.12 package classifier to pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 30bcc7a932..88689b20f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] keywords = [ From 8aadf73c865bc4fb903569b40c52805ccfcc5c99 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Fri, 10 Nov 2023 13:25:02 +0100 Subject: [PATCH 4/8] Run pre-commit only from min and max Python versions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5759ab1ea2..d505df3f8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ jobs: if: ${{ needs.changes.outputs.changes == 'true' }} strategy: matrix: - python-version: ["3.9", "3.11", "3.12"] + python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From bbf9d2e9f5cf935717ce6afd248043a934148e24 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 14 Jan 2024 20:02:39 +0100 Subject: [PATCH 5/8] Try ignoring the unused-ignore on py3.12 --- pytensor/tensor/shape.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pytensor/tensor/shape.py b/pytensor/tensor/shape.py index 75286b6690..cbf7192286 100644 --- a/pytensor/tensor/shape.py +++ b/pytensor/tensor/shape.py @@ -146,7 +146,9 @@ def c_code_cache_version(self): def shape(x: Union[np.ndarray, Number, Variable]) -> Variable: """Return the shape of `x`.""" if not isinstance(x, Variable): - x = ptb.as_tensor_variable(x) # type: ignore + # The following is a type error in Python 3.9 but not 3.12. + # Thus we need to ignore unused-ignore on 3.12. + x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore] return cast(Variable, _shape(x)) @@ -579,7 +581,9 @@ def specify_shape( # If the specified shape is already encoded in the input static shape, do nothing # This ignores PyTensor constants in shape - x = ptb.as_tensor_variable(x) # type: ignore + x = ptb.as_tensor_variable(x) # type: ignore[arg-type,unused-ignore] + # The above is a type error in Python 3.9 but not 3.12. + # Thus we need to ignore unused-ignore on 3.12. new_shape_info = any( s != xts for (s, xts) in zip(shape, x.type.shape) if s is not None ) From 4ad7fe31142134127c27e1861d0ebde196187860 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 14 Jan 2024 20:13:05 +0100 Subject: [PATCH 6/8] Upgrade mypy --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 644453950f..faad0cd4bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: ruff-format args: ["--line-length=88"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.0.0 + rev: v1.8.0 hooks: - id: mypy language: python From b029df0c4ab177ba5eda1c5752f7835ca93eef15 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 14 Jan 2024 20:25:56 +0100 Subject: [PATCH 7/8] Remove old numpy pin in CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d505df3f8c..b805b53539 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -139,7 +139,7 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | - mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl "numpy<1.26" scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy + mamba install --yes -q "python~=${PYTHON_VERSION}=*_cpython" mkl numpy scipy pip mkl-service graphviz cython pytest coverage pytest-cov pytest-benchmark pytest-mock sympy # numba-scipy downgrades the installed scipy to 1.7.3 in Python 3.9, but # not numpy, even though scipy 1.7 requires numpy<1.23. When installing # PyTensor next, pip installs a lower version of numpy via the PyPI. From 69319ef8795712427d41902e4fcf24260af716df Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 18 Jan 2024 10:28:31 +0100 Subject: [PATCH 8/8] Test Numba with Python 3.11 instead of 3.12 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b805b53539..0011c9714c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,7 +101,7 @@ jobs: float32: 0 part: "tests/link/numba" - install-numba: 1 - python-version: "3.12" + python-version: "3.11" # TODO: bump to 3.12 when numba 0.59 is released fast-compile: 0 float32: 0 part: "tests/link/numba"