Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7898dfc
Update CI Python version to 3.12.
BenZickel Apr 7, 2025
0ec521b
Try Python 3.11 as there is some problem with ruff.
BenZickel Apr 7, 2025
f5e168e
Go back to Python version 3.12 after fixing formatting to comply with…
BenZickel Apr 7, 2025
100c58c
Try going back to Python 3.11.
BenZickel Apr 7, 2025
73d26e0
Fix to comply with PEP 612 (see https://github.com/microsoft/pyright/…
BenZickel Apr 7, 2025
3e8b2bb
Fix typo
BenZickel Apr 7, 2025
03fb509
Go back to previous runtime.py and ignore mypy PEP 612 check.
BenZickel Apr 7, 2025
69da6e3
Back to Python 3.12,
BenZickel Apr 7, 2025
bc60b17
Back to Python 3.11.
BenZickel Apr 7, 2025
a9b2322
Update Sphinx version to 0.5.0.
BenZickel Apr 7, 2025
5e6ee87
Update Sphinx version to 8.2.3.
BenZickel Apr 7, 2025
3667f7f
Try removing Sphnix version in order solve dependency conflict.
BenZickel Apr 7, 2025
b806211
List all Python modules for CI debug.
BenZickel Apr 7, 2025
57acb33
Try with Python 3.12 due to https://github.com/jaraco/path/issues/231.
BenZickel Apr 7, 2025
5402a67
Unpin setuptools version.
BenZickel Apr 7, 2025
5ca95c4
Updated Sphinx version to 7.3.7.
BenZickel Apr 7, 2025
02e6143
Fix Sphinx issue (works on local machine).
BenZickel Apr 7, 2025
184b17c
Remove unused import.
BenZickel Apr 7, 2025
a4c49b8
Try different Sphinx versions.
BenZickel Apr 7, 2025
2bf65ba
Use Sphnix upgrade path.
BenZickel Apr 7, 2025
24b177e
Convert random seed to int data type.
BenZickel Apr 7, 2025
be9b5d6
Update levy-stable kstest.
BenZickel Apr 7, 2025
ef41099
Mark easyguide/test_easyguide.py::test_serialize as an expected failu…
BenZickel Apr 9, 2025
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
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -29,7 +29,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
pip install ruff black mypy nbstripout nbformat
- name: Lint
run: |
Expand All @@ -39,7 +39,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -51,7 +51,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build graphviz
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -67,7 +67,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -79,7 +79,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build graphviz pandoc
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -101,7 +101,7 @@ jobs:
needs: docs
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -113,7 +113,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -133,7 +133,7 @@ jobs:
needs: [docs, tutorials-html]
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -147,7 +147,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -169,7 +169,7 @@ jobs:
needs: docs
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -181,7 +181,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -201,7 +201,7 @@ jobs:
needs: docs
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -213,7 +213,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -233,7 +233,7 @@ jobs:
needs: docs
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -245,7 +245,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-9 g++-9 ninja-build
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
python -m pip install --upgrade pip wheel setuptools
# Keep track of pyro-api master branch
pip install https://github.com/pyro-ppl/pyro-api/archive/master.zip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Expand All @@ -267,7 +267,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0

sphinx==4.2.0
sphinx-rtd-theme==1.0.0
sphinx==7.3.7
sphinx-rtd-theme==3.0.0
graphviz>=0.8
numpy>=1.7
observations>=0.1.4
Expand Down
5 changes: 1 addition & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import os
import sys

import sphinx_rtd_theme

# import pkg_resources

# -*- coding: utf-8 -*-
Expand Down Expand Up @@ -82,7 +80,7 @@

if "READTHEDOCS" not in os.environ:
# if developing locally, use pyro.__version__ as version
from pyro import __version__ # noqaE402
from pyro import __version__ # noqa: E402

version = __version__

Expand Down Expand Up @@ -122,7 +120,6 @@
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
2 changes: 1 addition & 1 deletion examples/contrib/epidemiology/sir.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def evaluate(args, model, samples):
mean = samples[key].mean().item()
std = samples[key].std().item()
logging.info(
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00B1 {:0.3g}".format(
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00b1 {:0.3g}".format(
key, getattr(args, name), mean, std
)
)
Expand Down
2 changes: 1 addition & 1 deletion examples/sir_hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def evaluate(args, samples):
mean = samples[key].mean().item()
std = samples[key].std().item()
logging.info(
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00B1 {:0.3g}".format(
"{}: truth = {:0.3g}, estimate = {:0.3g} \u00b1 {:0.3g}".format(
key, getattr(args, name), mean, std
)
)
Expand Down
32 changes: 16 additions & 16 deletions examples/toy_mixture_model_discrete_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# SPDX-License-Identifier: Apache-2.0

"""
A toy mixture model to provide a simple example for implementing discrete enumeration.

(A) -> [B] -> (C)

A is an observed Bernoulli variable with Beta prior.
B is a hidden variable which is a mixture of two Bernoulli distributions (with Beta priors),
chosen by A being true or false.
C is observed, and like B, is a mixture of two Bernoulli distributions (with Beta priors),
chosen by B being true or false.
There is a plate over the three variables for n independent observations of data.

Because B is hidden and discrete we wish to marginalize it out of the model.
This is done by:
1) marking the model method with `@pyro.infer.config_enumerate`
2) marking the B sample site in the model with `infer={"enumerate": "parallel"}`
3) passing `pyro.infer.SVI` the `pyro.infer.TraceEnum_ELBO` loss function
A toy mixture model to provide a simple example for implementing discrete enumeration.

(A) -> [B] -> (C)

A is an observed Bernoulli variable with Beta prior.
B is a hidden variable which is a mixture of two Bernoulli distributions (with Beta priors),
chosen by A being true or false.
C is observed, and like B, is a mixture of two Bernoulli distributions (with Beta priors),
chosen by B being true or false.
There is a plate over the three variables for n independent observations of data.

Because B is hidden and discrete we wish to marginalize it out of the model.
This is done by:
1) marking the model method with `@pyro.infer.config_enumerate`
2) marking the B sample site in the model with `infer={"enumerate": "parallel"}`
3) passing `pyro.infer.SVI` the `pyro.infer.TraceEnum_ELBO` loss function
"""

import argparse
Expand Down
2 changes: 1 addition & 1 deletion pyro/contrib/epidemiology/compartmental.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def transition(self, params, state, t): ...
model = MyModel(...)
model.fit_svi(num_samples=100) # or .fit_mcmc(...)
R0 = model.samples["R0"] # An example parameter.
print("R0 = {:0.3g} \u00B1 {:0.3g}".format(R0.mean(), R0.std()))
print("R0 = {:0.3g} \u00b1 {:0.3g}".format(R0.mean(), R0.std()))

# Predict latent variables.
samples = model.predict()
Expand Down
4 changes: 2 additions & 2 deletions pyro/contrib/gp/models/sgpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SparseGPRegression(GPModel):
the covariance matrix :math:`k(X, X)` will require a lot of computational steps to
compute its inverse (for log likelihood and for prediction). By introducing an
additional inducing-input parameter :math:`X_u`, we can reduce computational cost
by approximate :math:`k(X, X)` by a low-rank Nystr\u00F6m approximation :math:`Q`
by approximate :math:`k(X, X)` by a low-rank Nystr\u00f6m approximation :math:`Q`
(see reference [1]), where

.. math:: Q = k(X, X_u) k(X_u,X_u)^{-1} k(X_u, X).
Expand Down Expand Up @@ -72,7 +72,7 @@ class SparseGPRegression(GPModel):
References:

[1] `A Unifying View of Sparse Approximate Gaussian Process Regression`,
Joaquin Qui\u00F1onero-Candela, Carl E. Rasmussen
Joaquin Qui\u00f1onero-Candela, Carl E. Rasmussen

[2] `Variational learning of inducing variables in sparse Gaussian processes`,
Michalis Titsias
Expand Down
2 changes: 1 addition & 1 deletion pyro/nn/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def __getstate__(self) -> Dict[str, Any]:


def pyro_method(
fn: Callable[Concatenate[_PyroModule, _P], _T]
fn: Callable[Concatenate[_PyroModule, _P], _T],
) -> Callable[Concatenate[_PyroModule, _P], _T]:
"""
Decorator for top-level methods of a :class:`PyroModule` to enable pyro
Expand Down
2 changes: 1 addition & 1 deletion pyro/poutine/block_messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _make_default_hide_fn(


def _negate_fn(
fn: Callable[["Message"], Optional[bool]]
fn: Callable[["Message"], Optional[bool]],
) -> Callable[["Message"], bool]:
# typed version of lambda msg: not fn(msg)
def negated_fn(msg: "Message") -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pyro/poutine/messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def unregister(

@contextmanager
def block_messengers(
predicate: Callable[[Messenger], bool]
predicate: Callable[[Messenger], bool],
) -> Iterator[List[Messenger]]:
"""
EXPERIMENTAL Context manager to temporarily remove matching messengers from
Expand Down
2 changes: 1 addition & 1 deletion pyro/poutine/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def effectful(
assert type != "message", "cannot use 'message' as keyword"

@functools.wraps(fn)
def _fn(
def _fn( # type: ignore[valid-type]
*args: _P.args,
name: Optional[str] = None,
infer: Optional[InferDict] = None,
Expand Down
2 changes: 1 addition & 1 deletion pyro/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,6 @@ def torch_float(x: Union[float, int]) -> float: ...
@overload
def torch_float(x: torch.Tensor) -> torch.Tensor: ...
def torch_float(
x: Union[torch.Tensor, Union[float, int]]
x: Union[torch.Tensor, Union[float, int]],
) -> Union[torch.Tensor, float]:
return x.float() if isinstance(x, torch.Tensor) else float(x)
Loading