Skip to content

Add experimental dims module with objects that follow dim-based semantics (like xarray without coordinates) #7820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ jobs:
tests/logprob/test_transforms.py
tests/logprob/test_utils.py

- |
tests/dims/distributions/test_core.py
tests/dims/distributions/test_scalar.py
tests/dims/distributions/test_vector.py
tests/dims/test_model.py

fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-alternative-backends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
- numpyro>=0.8.0
- pandas>=0.24.0
- pip
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- networkx
- rich>=13.7.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- numpy>=1.25.0
- pandas>=0.24.0
- pip
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- networkx
- scipy>=1.4.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- numpy>=1.25.0
- pandas>=0.24.0
- pip
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- rich>=13.7.1
- scipy>=1.4.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- pandas>=0.24.0
- pip
- polyagamma
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- networkx
- rich>=13.7.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/windows-environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- numpy>=1.25.0
- pandas>=0.24.0
- pip
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- networkx
- rich>=13.7.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/windows-environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- pandas>=0.24.0
- pip
- polyagamma
- pytensor>=2.31.2,<2.32
- pytensor>=2.31.7,<2.32
- python-graphviz
- networkx
- rich>=13.7.1
Expand Down
1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ API
api/backends
api/misc
api/testing
api/dims

------------------
Dimensionality
Expand Down
18 changes: 18 additions & 0 deletions docs/source/api/dims.rst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current preview of this page: https://pymcio--7820.org.readthedocs.build/projects/docs/en/7820/api/dims.html. I had to enter the url manually because it is not part of the toctree, it should be added to https://github.com/pymc-devs/pymc/blob/main/docs/source/api.rst?plain=1#L7-L25 (adding it here will also make the page have a sidebar like the other api pages)

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _api_dims:

Dims
====

This submodule contains functions for defining distributions and operations that use explicit dimensions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably add a warning about the module here too


The module is presented in :ref:`dims_module`.

.. currentmodule:: pymc.dims

.. autosummary::
:toctree: generated/
Comment on lines +10 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a toctree directive only as (for now) it is listing other doc pages, not yet pymc objects

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you propose the changes with github comment thing? I'm not sure if I should take autosummary or something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to and didn't work, now it does allow me:

Suggested change
.. currentmodule:: pymc.dims
.. autosummary::
:toctree: generated/
.. toctree::


dims/model
dims/math
dims/distributions
dims/transforms
36 changes: 36 additions & 0 deletions docs/source/api/dims/distributions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
********************
Scalar distributions
********************

.. currentmodule:: pymc.dims
.. autosummary::
:toctree: generated/
:template: distribution.rst

Flat
HalfFlat
Normal
HalfNormal
LogNormal
StudentT
HalfStudentT
Cauchy
HalfCauchy
Beta
Laplace
Gamma
InverseGamma


********************
Vector distributions
********************

.. currentmodule:: pymc.dims
.. autosummary::
:toctree: generated/
:template: distribution.rst

Categorical
MvNormal
ZeroSumNormal
9 changes: 9 additions & 0 deletions docs/source/api/dims/math.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
***************************************
Mathematical operations with dimensions
***************************************

This module wraps all the mathematical operations defined in :doc:`pytensor.xtensor.math <pytensor:libdoc_xtensor_math>`.

It includes a ``linalg`` submodule that wraps all the operations defined in :doc:`pytensor.xtensor.linalg <pytensor:libdoc_xtensor_linalg>`.

Operations defined at the module level in :doc:`pytensor.xtensor <pytensor:libdoc_xtensor_module_function>` are available at the parent model in ``pymc.dims`` instead of in here.
11 changes: 11 additions & 0 deletions docs/source/api/dims/model.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
******************
Model constructors
******************

.. currentmodule:: pymc.dims
.. autosummary::
:toctree: generated/

Data
Deterministic
Potential
11 changes: 11 additions & 0 deletions docs/source/api/dims/transforms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
***********************
Distribution Transforms
***********************

.. currentmodule:: pymc.dims.transforms
.. autosummary::
:toctree: generated/

LogTransform
LogOddsTransform
ZeroSumTransform
Loading
Loading