Skip to content

Commit 057a6d2

Browse files
committed
Bump PyTensor dependency
1 parent 2d4f4da commit 057a6d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+891
-890
lines changed

conda-envs/environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- numpy>=1.15.0
1414
- pandas>=0.24.0
1515
- pip
16-
- pytensor>=2.22.1,<2.23
16+
- pytensor>=2.23,<2.24
1717
- python-graphviz
1818
- networkx
1919
- scipy>=1.4.1

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.15.0
1212
- pandas>=0.24.0
1313
- pip
14-
- pytensor>=2.22.1,<2.23
14+
- pytensor>=2.23,<2.24
1515
- python-graphviz
1616
- rich>=13.7.1
1717
- scipy>=1.4.1

conda-envs/environment-jax.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- numpyro>=0.8.0
2121
- pandas>=0.24.0
2222
- pip
23-
- pytensor>=2.22.1,<2.23
23+
- pytensor>=2.23,<2.24
2424
- python-graphviz
2525
- networkx
2626
- rich>=13.7.1

conda-envs/environment-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- numpy>=1.15.0
1717
- pandas>=0.24.0
1818
- pip
19-
- pytensor>=2.22.1,<2.23
19+
- pytensor>=2.23,<2.24
2020
- python-graphviz
2121
- networkx
2222
- rich>=13.7.1

conda-envs/windows-environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- numpy>=1.15.0
1414
- pandas>=0.24.0
1515
- pip
16-
- pytensor>=2.22.1,<2.23
16+
- pytensor>=2.23,<2.24
1717
- python-graphviz
1818
- networkx
1919
- rich>=13.7.1

conda-envs/windows-environment-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- numpy>=1.15.0
1717
- pandas>=0.24.0
1818
- pip
19-
- pytensor>=2.22.1,<2.23
19+
- pytensor>=2.23,<2.24
2020
- python-graphviz
2121
- networkx
2222
- rich>=13.7.1

docs/source/contributing/implementing_distribution.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,9 @@ from typing import List, Tuple
4343
class BlahRV(RandomVariable):
4444
name: str = "blah"
4545

46-
# Provide the minimum number of (output) dimensions for this RV
47-
# (e.g. `0` for a scalar, `1` for a vector, etc.)
48-
ndim_supp: int = 0
49-
50-
# Provide the number of (input) dimensions for each parameter of the RV
51-
# (e.g. if there's only one vector parameter, `[1]`; for two parameters,
52-
# one a matrix and the other a scalar, `[2, 0]`; etc.)
53-
ndims_params: List[int] = [0, 0]
46+
# Provide a numpy-style signature for this RV, which indicates
47+
# the number and core dimensionality of each input and output.
48+
signature: "(),()->()"
5449

5550
# The NumPy/PyTensor dtype for this RV (e.g. `"int32"`, `"int64"`).
5651
# The standard in the library is `"int64"` for discrete variables
@@ -87,8 +82,8 @@ blah = BlahRV()
8782
Some important things to keep in mind:
8883

8984
1. Everything inside the `rng_fn` method is pure Python code (as are the inputs) and should __not__ make use of other `PyTensor` symbolic ops. The random method should make use of the `rng` which is a NumPy {class}`~numpy.random.RandomGenerator`, so that samples are reproducible.
90-
1. Non-default `RandomVariable` dimensions will end up in the `rng_fn` via the `size` kwarg. The `rng_fn` will have to take this into consideration for correct output. `size` is the specification used by NumPy and SciPy and works like PyMC `shape` for univariate distributions, but is different for multivariate distributions. For multivariate distributions the __`size` excludes the `ndim_supp` support dimensions__, whereas the __`shape` of the resulting `TensorVariable` or `ndarray` includes the support dimensions__. For more context check {ref}`The dimensionality notebook <dimensionality>`.
91-
1. `PyTensor` can automatically infer the output shape of univariate `RandomVariable`s (`ndim_supp=0`). For multivariate distributions (`ndim_supp>=1`), the method `_supp_shape_from_params` must be implemented in the new `RandomVariable` class. This method returns the support dimensionality of an RV given its parameters. In some cases this can be derived from the shape of one of its parameters, in which case the helper {func}`pytensor.tensor.random.utils.supp_shape_from_ref_param_shape` cand be used as is in {class}`~pymc.DirichletMultinomialRV`. In other cases the argument values (and not their shapes) may determine the support shape of the distribution, as happens in the `~pymc.distributions.multivarite._LKJCholeskyCovRV`. In simpler cases they may be constant.
85+
1. Non-default `RandomVariable` dimensions will end up in the `rng_fn` via the `size` kwarg. The `rng_fn` will have to take this into consideration for correct output. `size` is the specification used by NumPy and SciPy and works like PyMC `shape` for univariate distributions, but is different for multivariate distributions. For multivariate distributions the __`size` excludes the support dimensions__, whereas the __`shape` of the resulting `TensorVariable` or `ndarray` includes the support dimensions__. For more context check {ref}`The dimensionality notebook <dimensionality>`.
86+
1. `PyTensor` can automatically infer the output shape of univariate `RandomVariable`s. For multivariate distributions, the method `_supp_shape_from_params` must be implemented in the new `RandomVariable` class. This method returns the support dimensionality of an RV given its parameters. In some cases this can be derived from the shape of one of its parameters, in which case the helper {func}`pytensor.tensor.random.utils.supp_shape_from_ref_param_shape` cand be used as is in {class}`~pymc.DirichletMultinomialRV`. In other cases the argument values (and not their shapes) may determine the support shape of the distribution, as happens in the `~pymc.distributions.multivarite._LKJCholeskyCovRV`. In simpler cases they may be constant.
9287
1. It's okay to use the `rng_fn` `classmethods` of other PyTensor and PyMC `RandomVariables` inside the new `rng_fn`. For example if you are implementing a negative HalfNormal `RandomVariable`, your `rng_fn` can simply return `- halfnormal.rng_fn(rng, scale, size)`.
9388

9489
*Note: In addition to `size`, the PyMC API also provides `shape`, `dims` and `observed` as alternatives to define a distribution dimensionality, but this is taken care of by {class}`~pymc.Distribution`, and should not require any extra changes.*

0 commit comments

Comments
 (0)