Skip to content

Commit c4eceb4

Browse files
vandaltdfmpre-commit-ci[bot]
authored
Support PyMC v5 (#309)
* Implementing support for pymc v4 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * workflow error * workflow * allow python version for lint * getting distributions to work * some tweaks for pymc3 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pymc3 fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactoring distributions again * docstrings for distributions * starting to re-write docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * lint and starting to update tutorials * fixing some eccentricity dist issues * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updating docs * updating citations * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update README [ci skip] * making orphan page [ci skip] * Require PyMC < 5 for PyMC v4 version of exoplanet * Require pymc >= 5 in setup.py Left TODO comments about other exoplanet-dev packages. No released version yet but their main branch has support for pymc >= 5 * Replace aesara by pytensor and pymc4 by pymc The actual imports are in the compat module, but I updated `at` to `pt`. That way `exoplanet` stays up to date with latest "notation" for `pytensor.tensor` * Add upper limit on xarray for pymc3 Causes numpy error for Python >= 3.9 otherwise * Accept pre-commit changes on tutorial notebooks * Replace `AESARA_FLAGS` by `PYTENSOR_FLAGS` in `pytest.ini` * Update docs from PyMC 4 to PyMC 5 (mostly pytensor -> Aesara) * Comment-out warnings in `docs_setup()` with TODO to maybe remove them * TODO comment for deprecated `pt.opt.Assert` * Update `Evaluator()` call to use `model` kwarg * Replace testval by initval and start by initvals * Enable using kipping13 prior when eccentricity is a derived parameter In PyMC 3, we could just used `observed=ecc` with any distribution. In PyMC >= 5, we need to use a `pm.Potential` * Add `_truncate_dist` helper function for eccentricity prior * Fix vanelyen19 prior when eccentricity is a derived parameter Same as kipping13: if eccentricity is "observed" (derived), extra prior must be a `pm.Potential` * Test `angle()` and `unit_disk()` distributions and fix shape error Previously, default initval was hardcoded so passing shape without initval caused error. Added failing tests and fixed * Pop initval when ecc is None only when bounds are set * Clean-up `_truncate_dist()` helper function * Raise `NotImplementedError` when trying to pass observed ecc with bounds in kipping13 This did not work with the original PyMC3 implementation either, but is supported in PyMC 5. This error makes it a bit clearer * Test eccentricity priors with and without bounds * Update required Python version from 3.6 to 3.8 in docs * Convert shape from `int` to `tuple` for pymc>3 in impact parameter distribution * Remove deprecated `pt.opt.Assert` in favor of `Assert` from `compat` * Remove leftover commented-out warning filters * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace tox dependency by nox * Check that kipping13_observed raises error with bounds when using PyMC3 * Get shape using `tag.test_value` for PyMC3 tests `type.shape` works only in PyMC > 3 * Remove extra potential in vaneylen19 distribution PyMC 3 version The implementation that worked with PyMC v5 did not in PyMC3 * Update dependency versions for PyMC v5 * Add `exoplanet-core` dependency to `docs` Had to remove from the main dependencies because no of the different versions for PyMC3 and PyMC 5 * Another merge conflict * Range of tests for deps * Don't install coverage --------- Co-authored-by: Dan F-M <foreman.mackey@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3bfeb14 commit c4eceb4

Some content is hidden

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

57 files changed

+1782
-1623
lines changed

.clang-format

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
paper/* linguist-documentation
22
docs/* linguist-documentation
3-
exoplanet/theano_ops/vendor/* linguist-vendored
43
*.h linguist-language=C++
54
docs/notebooks/*.ipynb filter=nbstripout
65
paper/figures/*.ipynb filter=nbstripout

.github/workflows/tests.yml

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,76 +13,46 @@ on:
1313

1414
jobs:
1515
tests:
16-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.9", "3.10"]
20+
python-version: ["3.10"]
21+
os: ["ubuntu-latest"]
22+
session: ["test_pymc3", "test_pymc"]
23+
include:
24+
- python-version: "3.9"
25+
os: "ubuntu-latest"
26+
session: "test_pymc3"
27+
- python-version: "3.11"
28+
os: "ubuntu-latest"
29+
session: "test_pymc"
30+
- python-version: "3.10"
31+
os: "ubuntu-latest"
32+
session: "lint"
2133

2234
steps:
2335
- name: Checkout
2436
uses: actions/checkout@v4
2537
with:
2638
fetch-depth: 0
2739

28-
- name: Setup Python
29-
uses: actions/setup-python@v5
40+
- uses: actions/setup-python@v4
41+
name: Install Python
3042
with:
3143
python-version: ${{ matrix.python-version }}
3244

3345
- name: Install dependencies
3446
run: |
3547
python -m pip install -U pip
36-
python -m pip install -U coveralls coverage[toml] tox tox-gh-actions
48+
python -m pip install -U nox
3749
3850
- name: Run tests
39-
run: python -m tox
40-
41-
- name: Combine and upload coverage
42-
run: |
43-
python -m coverage combine
44-
python -m coverage xml -i
45-
python -m coveralls --service=github
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
COVERALLS_PARALLEL: true
49-
COVERALLS_FLAG_NAME: py${{ matrix.python-version }}
50-
51-
coverage:
52-
needs: tests
53-
runs-on: ubuntu-latest
54-
steps:
55-
- name: Setup Python
56-
uses: actions/setup-python@v5
57-
with:
58-
python-version: "3.9"
59-
- name: Finish coverage collection
60-
run: |
61-
python -m pip install -U pip
62-
python -m pip install -U coveralls
63-
python -m coveralls --finish
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
67-
lint:
68-
runs-on: ubuntu-latest
69-
steps:
70-
- uses: actions/checkout@v4
71-
with:
72-
fetch-depth: 0
73-
74-
- name: Setup Python
75-
uses: actions/setup-python@v5
76-
with:
77-
python-version: "3.9"
78-
79-
- name: Install dependencies
8051
run: |
81-
python -m pip install -U pip
82-
python -m pip install tox
83-
84-
- name: Lint the code
85-
run: python -m tox -e lint
52+
python -m nox --non-interactive \
53+
--error-on-missing-interpreter \
54+
--python ${{ matrix.python-version }} \
55+
--session ${{ matrix.session }}
8656
8757
build:
8858
runs-on: ubuntu-latest
@@ -104,7 +74,7 @@ jobs:
10474
path: dist/*
10575

10676
upload_pypi:
107-
needs: [tests, lint, build]
77+
needs: [tests, build]
10878
runs-on: ubuntu-latest
10979
if: startsWith(github.ref, 'refs/tags/')
11080
steps:

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
Fast & scalable MCMC for all your exoplanet needs! _exoplanet_ is a toolkit for
1818
probabilistic modeling of time series data in astronomy with a focus on
1919
observations of [exoplanets](https://en.wikipedia.org/wiki/Exoplanet), using
20-
[PyMC3](https://docs.pymc.io). _PyMC3_ is a flexible and high-performance model
21-
building language and inference engine that scales well to problems with a large
22-
number of parameters. _exoplanet_ extends _PyMC3_'s language to support many of
23-
the custom functions and distributions required when fitting exoplanet datasets.
20+
[PyMC](https://www.pymc.io). _PyMC_ is a flexible and high-performance
21+
model-building language and inference engine that scales well to problems with a
22+
large number of parameters. _exoplanet_ extends _PyMC_'s language to support
23+
many of the custom functions and distributions required when fitting exoplanet
24+
datasets.
2425

2526
Read the full documentation at [docs.exoplanet.codes](https://docs.exoplanet.codes).
2627

@@ -29,7 +30,7 @@ Read the full documentation at [docs.exoplanet.codes](https://docs.exoplanet.cod
2930
The quickest way to get started is to use [pip](https://pip.pypa.io):
3031

3132
```bash
32-
python -m pip install exoplanet
33+
python -m pip install "exoplanet[pymc]"
3334
```
3435

3536
Note that you will need Python (>=3.6) installed for this to work, but then this
@@ -47,7 +48,7 @@ page](https://gallery.exoplanet.codes).
4748

4849
## Contributing
4950

50-
_exoplanet_ is an open source project and we would love it if you wanted to
51+
_exoplanet_ is an open-source project, and we would love it if you wanted to
5152
contribute. Check out [the developer
5253
documentation](https://docs.exoplanet.codes/en/latest/user/dev/) for more info
5354
about getting started.

binder/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ pymc3-ext>=0.1.0
88
emcee
99
numpy<1.22
1010
xarray<2023.10.0
11-
.
11+
.[docs]

docs/index.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ exoplanet
33

44
*exoplanet* is a toolkit for probabilistic modeling of time series data in
55
astronomy with a focus on observations of `exoplanets
6-
<https://en.wikipedia.org/wiki/Exoplanet>`_, using `PyMC3
7-
<https://docs.pymc.io>`_. *PyMC3* is a flexible and high-performance model
6+
<https://en.wikipedia.org/wiki/Exoplanet>`_, using `PyMC
7+
<https://www.pymc.io>`_. *PyMC* is a flexible and high-performance model
88
building language and inference engine that scales well to problems with a large
9-
number of parameters. *exoplanet* extends *PyMC3*'s language to support many of
9+
number of parameters. *exoplanet* extends *PyMC*'s language to support many of
1010
the custom functions and distributions required when fitting exoplanet datasets.
1111
These features include:
1212

@@ -44,13 +44,13 @@ an issue <https://github.com/exoplanet-dev/exoplanet/issues>`_ there.
4444
🖼 For more in depth examples of *exoplanet* used for more realistic problems,
4545
go to the `Case studies page <https://gallery.exoplanet.codes>`_.
4646

47-
📈 For more information about scalable Gaussian Processes in PyMC3 (this was
47+
📈 For more information about scalable Gaussian Processes in PyMC (this was
4848
previously implemented as part of *exoplanet*), see the `celerite2 documentation
4949
page <https://celerite2.readthedocs.io>`_.
5050

51-
👉 For helper functions and PyMC3 extras that used to be implemented as part of
52-
*exoplanet*, see the `pymc3-ext project
53-
<https://github.com/exoplanet-dev/pymc3-ext>`_.
51+
👉 For helper functions and PyMC extras that used to be implemented as part of
52+
*exoplanet*, see the `pymc-ext project
53+
<https://github.com/exoplanet-dev/pymc-ext>`_.
5454

5555

5656
Contents
@@ -62,7 +62,6 @@ Contents
6262

6363
user/install
6464
tutorials/citation.md
65-
user/theano
6665
user/multiprocessing
6766
user/api
6867
user/dev
@@ -74,7 +73,7 @@ Contents
7473

7574
tutorials/about.md
7675
tutorials/autodiff.md
77-
tutorials/intro-to-pymc3.md
76+
tutorials/intro-to-pymc.md
7877
tutorials/data-and-models.md
7978
tutorials/light-delay.md
8079
tutorials/reparameterization.md

docs/tutorials/about.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupytext:
66
format_version: 0.13
77
jupytext_version: 1.15.2
88
kernelspec:
9-
display_name: Python 3
9+
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
@@ -15,8 +15,8 @@ kernelspec:
1515

1616
+++
1717

18-
This and the following tutorials are automatically executed with every change of the code to make sure that they are always up to date with the code.
19-
As a result, they are designed to require only a relatively small amount of computation time; when using `exoplanet` for research you will probably find that your runtimes are longer.
18+
This and the following tutorials are automatically executed with every change of the code to make sure that they are always up-to-date with the code.
19+
As a result, they are designed to require only a relatively small amount of computation time; when using `exoplanet` for research you will probably find that your run times are longer.
2020
For more in-depth tutorials with real-world applications and real data, check out the [Case Studies page](https://gallery.exoplanet.codes).
2121

2222
At the top of each tutorial, you'll find a cell like the following that indicates the version of `exoplanet` that was used to generate the tutorial:
@@ -28,9 +28,9 @@ exoplanet.utils.docs_setup()
2828
print(f"exoplanet.__version__ = '{exoplanet.__version__}'")
2929
```
3030

31-
That cell also includes a call to the `exoplanet.utils.docs_setup` function that will squash some warnings (these are generally caused by Theano/Aesara; see {ref}`theano` for more info) and set up our `matplotlib` style.
31+
That cell also includes a call to the `exoplanet.utils.docs_setup` function that will squash some warnings (these are generally caused by Theano/PyTensor) and set up our `matplotlib` style.
3232

33-
To exectute a tutorial on your own, you can click on the buttons at the top right or this page to launch the notebook using [Binder](https://mybinder.org) or download the `.ipynb` file directly.
33+
To execute a tutorial on your own, you can click on the buttons at the top right or this page to launch the notebook using [Binder](https://mybinder.org) or download the `.ipynb` file directly.
3434

3535
```{code-cell}
3636

0 commit comments

Comments
 (0)