Skip to content

Commit e5eb8c9

Browse files
committed
Bump PyTensor dependency and test on 3.14
Co-authored-by: PatrickRobotham
1 parent cadb97a commit e5eb8c9

File tree

14 files changed

+30
-26
lines changed

14 files changed

+30
-26
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
matrix:
5959
os: [ubuntu-latest]
6060
floatx: [float64]
61-
python-version: ["3.13"]
61+
python-version: ["3.14"]
6262
test-subset:
6363
- |
6464
tests/test_util.py
@@ -237,7 +237,7 @@ jobs:
237237
matrix:
238238
os: [macos-latest]
239239
floatx: [float64]
240-
python-version: ["3.13"]
240+
python-version: ["3.14"]
241241
test-subset:
242242
- |
243243
tests/sampling/test_parallel.py
@@ -295,7 +295,7 @@ jobs:
295295
matrix:
296296
os: [ubuntu-latest]
297297
floatx: [float64]
298-
python-version: ["3.13"]
298+
python-version: ["3.14"]
299299
test-subset:
300300
- |
301301
tests/distributions/test_random_alternative_backends.py
@@ -345,7 +345,7 @@ jobs:
345345
matrix:
346346
os: [windows-latest]
347347
floatx: [float32]
348-
python-version: ["3.13"]
348+
python-version: ["3.14"]
349349
test-subset:
350350
- tests/sampling/test_mcmc.py tests/ode/test_ode.py tests/ode/test_utils.py tests/distributions/test_transform.py
351351
fail-fast: false

conda-envs/environment-alternative-backends.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
- numpyro>=0.8.0
2323
- pandas>=0.24.0
2424
- pip
25-
- pytensor>=2.35.0,<2.36
25+
- pytensor>=2.36.0,<2.37
2626
- python-graphviz
2727
- networkx
2828
- rich>=13.7.1
@@ -35,7 +35,7 @@ dependencies:
3535
- pre-commit>=2.8.0
3636
- pytest-cov>=2.5
3737
- pytest>=3.0
38-
- mypy=1.15.0
38+
- mypy=1.19.1
3939
- types-cachetools
4040
- pip:
4141
- numdifftools>=0.9.40

conda-envs/environment-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- numpy>=1.25.0
1313
- pandas>=0.24.0
1414
- pip
15-
- pytensor>=2.35.0,<2.36
15+
- pytensor>=2.36.0,<2.37
1616
- python-graphviz
1717
- networkx
1818
- scipy>=1.4.1
@@ -37,7 +37,7 @@ dependencies:
3737
- sphinxext-rediraffe
3838
- watermark
3939
- sphinx-remove-toctrees
40-
- mypy=1.15.0
40+
- mypy=1.19.1
4141
- types-cachetools
4242
- pip:
4343
- pymc-sphinx-theme>=0.16.0

conda-envs/environment-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- numpy>=1.25.0
1212
- pandas>=0.24.0
1313
- pip
14-
- pytensor>=2.35.0,<2.36
14+
- pytensor>=2.36.0,<2.37
1515
- python-graphviz
1616
- rich>=13.7.1
1717
- scipy>=1.4.1

conda-envs/environment-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- pandas>=0.24.0
1515
- pip
1616
- polyagamma
17-
- pytensor>=2.35.0,<2.36
17+
- pytensor>=2.36.0,<2.37
1818
- python-graphviz
1919
- networkx
2020
- rich>=13.7.1
@@ -27,7 +27,7 @@ dependencies:
2727
- pre-commit>=2.8.0
2828
- pytest-cov>=2.5
2929
- pytest>=3.0
30-
- mypy=1.15.0
30+
- mypy=1.19.1
3131
- types-cachetools
3232
- pip:
3333
- numdifftools>=0.9.40

conda-envs/windows-environment-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- numpy>=1.25.0
1313
- pandas>=0.24.0
1414
- pip
15-
- pytensor>=2.35.0,<2.36
15+
- pytensor>=2.36.0,<2.37
1616
- python-graphviz
1717
- networkx
1818
- rich>=13.7.1
@@ -35,7 +35,7 @@ dependencies:
3535
- sphinx>=1.5
3636
- watermark
3737
- sphinx-remove-toctrees
38-
- mypy=1.15.0
38+
- mypy=1.19.1
3939
- types-cachetools
4040
- pip:
4141
- git+https://github.com/pymc-devs/pymc-sphinx-theme

conda-envs/windows-environment-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
- pandas>=0.24.0
1616
- pip
1717
- polyagamma
18-
- pytensor>=2.35.0,<2.36
18+
- pytensor>=2.36.0,<2.37
1919
- python-graphviz
2020
- networkx
2121
- rich>=13.7.1
@@ -28,7 +28,7 @@ dependencies:
2828
- pre-commit>=2.8.0
2929
- pytest-cov>=2.5
3030
- pytest>=3.0
31-
- mypy=1.15.0
31+
- mypy=1.19.1
3232
- types-cachetools
3333
- pip:
3434
- numdifftools>=0.9.40

pymc/distributions/multivariate.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
from pytensor.graph.basic import Apply, Variable
2626
from pytensor.graph.op import Op
2727
from pytensor.raise_op import Assert
28-
from pytensor.sparse.basic import DenseFromSparse, sp_sum
28+
from pytensor.sparse.basic import DenseFromSparse
29+
from pytensor.sparse.math import sp_sum
2930
from pytensor.tensor import (
3031
TensorConstant,
3132
TensorVariable,
@@ -2263,10 +2264,12 @@ class CAR(Continuous):
22632264
def dist(cls, mu, W, alpha, tau, *args, **kwargs):
22642265
# This variable has an expensive validation check, that we want to constant-fold if possible
22652266
# So it's passed as an explicit input
2266-
W = pytensor.sparse.as_sparse_or_tensor_variable(W)
2267+
from pytensor.sparse import as_sparse_or_tensor_variable, structured_sign
2268+
2269+
W = as_sparse_or_tensor_variable(W)
22672270
if isinstance(W.type, pytensor.sparse.SparseTensorType):
2268-
abs_diff = pytensor.sparse.basic.mul(pytensor.sparse.sign(W - W.T), W - W.T)
2269-
W_is_valid = pt.isclose(pytensor.sparse.sp_sum(abs_diff), 0)
2271+
abs_diff = structured_sign(W - W.T) * (W - W.T)
2272+
W_is_valid = pt.isclose(abs_diff.sum(), 0)
22702273
else:
22712274
W_is_valid = pt.allclose(W, W.T)
22722275

@@ -2307,7 +2310,7 @@ def logp(value, mu, W, alpha, tau, W_is_valid):
23072310
if W.owner and isinstance(W.owner.op, DenseFromSparse):
23082311
W = W.owner.inputs[0]
23092312

2310-
sparse = isinstance(W, pytensor.sparse.SparseVariable)
2313+
sparse = isinstance(W, pytensor.sparse.variable.SparseVariable)
23112314
if sparse:
23122315
D = sp_sum(W, axis=0)
23132316
Dinv_sqrt = pt.diag(1 / pt.sqrt(D))

pymc/distributions/shape_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def get_support_shape(
409409
]
410410

411411
if inferred_support_shape is None and observed is not None:
412-
observed = convert_observed_data(observed)
412+
observed = cast(TensorVariable | np.ndarray, convert_observed_data(observed))
413413
if observed.ndim < ndim_supp:
414414
raise ValueError(
415415
f"Number of observed dimensions is too small for ndim_supp of {ndim_supp}"

pymc/smc/sampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def _save_sample_stats(
274274
if idata_kwargs is not None:
275275
ikwargs.update(idata_kwargs)
276276
idata = to_inference_data(trace, **ikwargs)
277-
idata = InferenceData(**idata, sample_stats=sample_stats)
277+
idata = InferenceData(**idata, sample_stats=sample_stats) # type: ignore[arg-type]
278278

279279
return sample_stats, idata
280280

0 commit comments

Comments
 (0)