Skip to content

Commit

Permalink
Bump to 0.13.0 (#1629)
Browse files Browse the repository at this point in the history
* bump jax version to 0.4.14

* Bump to 0.13.0

* drop 3.8 in setup

* update typing for python 3.9

* more typing from collections.abc
  • Loading branch information
fehiepsi authored Aug 21, 2023
1 parent cc1ad02 commit d8e1156
Show file tree
Hide file tree
Showing 53 changed files with 81 additions and 159 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion examples/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Bayesian Models of Annotation")
parser.add_argument("-n", "--num-samples", nargs="?", default=1000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/ar2.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="AR2 example")
parser.add_argument("--num-data", nargs="?", default=142, type=int)
parser.add_argument("-n", "--num-samples", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/baseball.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Baseball batting average using MCMC")
parser.add_argument("-n", "--num-samples", nargs="?", default=3000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1500, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/bnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Bayesian neural network example")
parser.add_argument("-n", "--num-samples", nargs="?", default=2000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/covtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="parse args")
parser.add_argument(
"-n", "--num-samples", default=1000, type=int, help="number of samples"
Expand Down
2 changes: 1 addition & 1 deletion examples/funnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(
description="Non-centered reparameterization example"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/gaussian_shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Nested sampler for Gaussian shells")
parser.add_argument("-n", "--num-samples", nargs="?", default=10000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Gaussian Process example")
parser.add_argument("-n", "--num-samples", nargs="?", default=1000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Semi-supervised Hidden Markov Model")
parser.add_argument("--num-categories", default=3, type=int)
parser.add_argument("--num-words", default=10, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/holt_winters.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Holt-Winters")
parser.add_argument("--T", nargs="?", default=6, type=int)
parser.add_argument("--future", nargs="?", default=1, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/horseshoe_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Horseshoe regression example")
parser.add_argument("-n", "--num-samples", nargs="?", default=2000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/minipyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def body_fn(i, val):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Mini Pyro demo")
parser.add_argument("-f", "--full-pyro", action="store_true", default=False)
parser.add_argument("-n", "--num-steps", default=1001, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/mortality.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")

parser = argparse.ArgumentParser(description="Mortality regression model")
parser.add_argument("-n", "--num-samples", nargs="?", default=500, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/neutra.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="NeuTra HMC")
parser.add_argument("-n", "--num-samples", nargs="?", default=4000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Predator-Prey Model")
parser.add_argument("-n", "--num-samples", nargs="?", default=1000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/prodlda.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(
description="Probabilistic topic modelling with Flax and Haiku"
)
Expand Down
5 changes: 2 additions & 3 deletions examples/proportion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import argparse
import os
from typing import Tuple

from jax import random
import jax.numpy as jnp
Expand All @@ -31,7 +30,7 @@
from numpyro.infer import MCMC, NUTS


def make_dataset(rng_key) -> Tuple[jnp.ndarray, jnp.ndarray]:
def make_dataset(rng_key) -> tuple[jnp.ndarray, jnp.ndarray]:
"""
Make simulated dataset where potential customers who get a
sales calls have ~2% higher chance of making another purchase.
Expand Down Expand Up @@ -160,7 +159,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Testing whether ")
parser.add_argument("-n", "--num-samples", nargs="?", default=500, type=int)
parser.add_argument("--num-warmup", nargs="?", default=1500, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/sparse_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Gaussian Process example")
parser.add_argument("-n", "--num-samples", nargs="?", default=1000, type=int)
parser.add_argument("--num-warmup", nargs="?", default=500, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/stochastic_volatility.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Stochastic Volatility Model")
parser.add_argument("-n", "--num-samples", nargs="?", default=600, type=int)
parser.add_argument("--num-warmup", nargs="?", default=600, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/thompson_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Thompson sampling example")
parser.add_argument(
"--num-random", nargs="?", default=2, type=int, help="number of random draws"
Expand Down
2 changes: 1 addition & 1 deletion examples/toy_mixture_model_discrete_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_true_pred_CPDs(CPD, posterior_param):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="Toy mixture model")
parser.add_argument("-n", "--num-steps", default=4000, type=int)
parser.add_argument("-o", "--num-obs", default=10000, type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/ucbadmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main(args):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(
description="UCBadmit gender discrimination using HMC"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/vae.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def reconstruct_img(epoch, rng_key):


if __name__ == "__main__":
assert numpyro.__version__.startswith("0.12.1")
assert numpyro.__version__.startswith("0.13.0")
parser = argparse.ArgumentParser(description="parse args")
parser.add_argument(
"-n", "--num-epochs", default=15, type=int, help="number of training epochs"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/bad_posterior_geometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"\n",
"from numpyro.infer import MCMC, NUTS\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")\n",
"assert numpyro.__version__.startswith(\"0.13.0\")\n",
"\n",
"# NB: replace cpu by gpu to run this notebook on gpu\n",
"numpyro.set_platform(\"cpu\")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"import numpyro.distributions as dist\n",
"from jax import random\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/bayesian_hierarchical_stacking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
" set_matplotlib_formats(\"svg\")\n",
"\n",
"numpyro.set_host_device_count(4)\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/bayesian_imputation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"if \"NUMPYRO_SPHINXBUILD\" in os.environ:\n",
" set_matplotlib_formats(\"svg\")\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/bayesian_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"if \"NUMPYRO_SPHINXBUILD\" in os.environ:\n",
" set_matplotlib_formats(\"svg\")\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
],
"execution_count": 2,
"outputs": []
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/gmm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"%matplotlib inline\n",
"\n",
"smoke_test = \"CI\" in os.environ\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/logistic_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"from numpyro.examples.datasets import COVTYPE, load_dataset\n",
"from numpyro.infer import HMC, MCMC, NUTS\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")\n",
"assert numpyro.__version__.startswith(\"0.13.0\")\n",
"\n",
"# NB: replace gpu by cpu to run this notebook in cpu\n",
"numpyro.set_platform(\"gpu\")"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/model_rendering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"import numpyro.distributions as dist\n",
"import numpyro.distributions.constraints as constraints\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/ordinal_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"import pandas as pd\n",
"import seaborn as sns\n",
"\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/source/time_series_forecasting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
" set_matplotlib_formats(\"svg\")\n",
"\n",
"numpyro.set_host_device_count(4)\n",
"assert numpyro.__version__.startswith(\"0.12.1\")"
"assert numpyro.__version__.startswith(\"0.13.0\")"
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions numpyro/contrib/einstein/mixture_guide_predictive.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0

from collections.abc import Callable, Sequence
from functools import partial
from typing import Callable, Dict, Optional, Sequence
from typing import Optional

from jax import numpy as jnp, random, tree_map, vmap
from jax.tree_util import tree_flatten
Expand All @@ -24,7 +25,7 @@ class MixtureGuidePredictive:
:param Callable model: Python callable containing Pyro primitives.
:param Callable guide: Python callable containing Pyro primitives to get posterior samples of sites.
:param Dict params: Dictionary of values for param sites of model/guide
:param dict params: Dictionary of values for param sites of model/guide
:param Sequence guide_sites: Names of sites that contribute to the Stein mixture.
:param Optional[int] num_samples:
:param Optional[Sequence[str]] return_sites: Sites to return. By default, only sample sites not present
Expand All @@ -37,7 +38,7 @@ def __init__(
self,
model: Callable,
guide: Callable,
params: Dict,
params: dict,
guide_sites: Sequence,
num_samples: Optional[int] = None,
return_sites: Optional[Sequence[str]] = None,
Expand Down
Loading

0 comments on commit d8e1156

Please sign in to comment.