Skip to content

Docs in Markdown with Myst and change tutorials to Jupytext notebooks #355

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

Merged
merged 59 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b80e749
Convert RST to MD (myst)
basnijholt Sep 2, 2022
565ff81
Add myst_parser
basnijholt Sep 2, 2022
8962a33
Dedent code
basnijholt Sep 2, 2022
480485f
Remove m2r2 from docs/environment.yml
basnijholt Sep 2, 2022
8a352e9
Create references
basnijholt Sep 2, 2022
a9a599b
Towards single line sentences
basnijholt Sep 2, 2022
4de9174
Single sentence per line
basnijholt Sep 2, 2022
2111067
Add blacken-docs and format the pre-commit YAML
basnijholt Sep 2, 2022
b7438d7
Run blacken-docs and remove as pre-commit filter because it doesn't work
basnijholt Sep 2, 2022
b54b3c2
Do not us %% magic in notebook
basnijholt Sep 2, 2022
858776e
Remove all use of HoloViews magics
basnijholt Sep 2, 2022
6c97a21
Fix notebook directive
basnijholt Sep 2, 2022
f0025b2
Make tutorial headers not clickable
basnijholt Sep 2, 2022
34f70b7
Use triple backticks instead of :::
basnijholt Sep 2, 2022
4e0a16a
Bump jupyter-sphinx and scipy requirement
basnijholt Sep 2, 2022
0d550b0
Fix cross links
basnijholt Sep 2, 2022
bc5f3eb
Single sentence README.rst
basnijholt Sep 2, 2022
20637a3
Move to Jupytext notebooks
basnijholt Sep 2, 2022
080e9ef
Bump scipy
basnijholt Sep 2, 2022
050aedd
Pin myst_nb
basnijholt Sep 2, 2022
581322a
Fix Markdown include
basnijholt Sep 2, 2022
8063c3c
Rephrase first sentence of plot docstring
basnijholt Sep 2, 2022
35310e6
Change download directives
basnijholt Sep 2, 2022
b00810c
Fix hide-cell tags
basnijholt Sep 2, 2022
5891415
Add download footer
basnijholt Sep 2, 2022
77fbc04
Fix directives in docs/source/algorithms_and_examples.md
basnijholt Sep 2, 2022
ceb4a7f
Build docs in parallel
basnijholt Sep 2, 2022
969d994
Simplify the conf.py and use new theme and Myst-NB
basnijholt Sep 2, 2022
8b6ac4c
Make docs/source/algorithms_and_examples.md a Jupytext notebook
basnijholt Sep 2, 2022
dae9583
Better includes
basnijholt Sep 2, 2022
23a4ab0
Make single line list in algorithms_and_examples.md
basnijholt Sep 2, 2022
2458394
Convert README to Markdown
basnijholt Sep 2, 2022
6e3b46c
Install sphinx-book-theme in docs env
basnijholt Sep 2, 2022
8b441f1
Add see also for tutorial
basnijholt Sep 2, 2022
ae938c3
Style conf.py
basnijholt Sep 2, 2022
c1e228e
increase nb_execution_timeout to 180
basnijholt Sep 2, 2022
66bdd05
Make README a notebook to include the logo
basnijholt Sep 2, 2022
fe407b0
Remove animated logo script by notebook
basnijholt Sep 2, 2022
e7b8b69
Move download footer link to bottom
basnijholt Sep 2, 2022
85aa532
Fixes and change to furo
basnijholt Sep 2, 2022
3fc2ed8
se different YAML meta data format
basnijholt Sep 2, 2022
d966da4
Lower loss requirement
basnijholt Sep 2, 2022
010ed38
Fix links in notebooks
basnijholt Sep 3, 2022
16f58a0
Fix execution timeouts per notebook
basnijholt Sep 3, 2022
4d7be11
Only hide input not the output
basnijholt Sep 3, 2022
245d114
Define badges directly
basnijholt Sep 3, 2022
c770918
Add require.js
basnijholt Sep 3, 2022
230e73d
Set the Shpinx options in the correct place
basnijholt Sep 3, 2022
f2b158a
Rephase when to use
basnijholt Sep 3, 2022
d485138
Fix HTML of logo
basnijholt Sep 3, 2022
fb840cd
Hide comments in the README on GitHub too
basnijholt Sep 3, 2022
38fbb69
README.md doesn't need to be a notebook anymore
basnijholt Sep 3, 2022
88c945d
Fix link in README
basnijholt Sep 3, 2022
e732690
Change seealso in tip
basnijholt Sep 3, 2022
3271e89
Add header target for 1D tutorial
basnijholt Sep 3, 2022
624ac62
Update AUTHORS.md
basnijholt Sep 3, 2022
8e195cf
Change back to sphinx_rtd_theme because plotly isn't showing
basnijholt Sep 3, 2022
17c26d6
Fix plotly and use a custom 'base.html'
basnijholt Sep 3, 2022
f050e01
Less strict scipy pinning because it is not available in Python 3.7
basnijholt Sep 3, 2022
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
52 changes: 26 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: debug-statements
- id: check-ast
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
hooks:
- id: pyupgrade
args: ['--py37-plus']
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: debug-statements
- id: check-ast
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
26 changes: 15 additions & 11 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

The current maintainers of Adaptive are:

- [Bas Nijholt](<http://nijho.lt>)
- [Joseph Weston](<https://joseph.weston.cloud>)
- [Anton Akhmerov](<https://antonakhmerov.org>)
- [Bas Nijholt](<http://nijho.lt>) ([@basnijholt](https://github.com/basnijholt))
- [Joseph Weston](<https://joseph.weston.cloud>) ([@jbweston](https://github.com/jbweston))
- [Anton Akhmerov](<https://antonakhmerov.org>) ([@akhmerov](https://github.com/akhmerov))

Other contributors to Adaptive include:

- Andrey E. Antipov
- Andrey E. Antipov ([@aeantipov](https://github.com/aeantipov))
- [Christoph Groth](<http://inac.cea.fr/Pisp/christoph.groth/>)
- Jorn Hoofwijk
- Philippe Solodov (@philippeitis)
- Victor Negîrneac (@caenrigen)
- Thomas A Caswell (@tacaswell)
- Álvaro Gómez Iñesta (@AlvaroGI)
- Sultan Orazbayev (@SultanOrazbayev)
- Thomas Aarholt (@thomasaarholt)
- Jorn Hoofwijk ([@jhoofwijk](https://github.com/jhoofwijk))
- Philippe Solodov ([@philippeitis](https://github.com/philippeitis))
- Victor Negîrneac ([@caenrigen](https://github.com/caenrigen))
- Thomas A Caswell ([@tacaswell](https://github.com/tacaswell))
- Álvaro Gómez Iñesta ([@AlvaroGI](https://github.com/AlvaroGI))
- Sultan Orazbayev ([@SultanOrazbayev](https://github.com/SultanOrazbayev))
- Thomas Aarholt ([@thomasaarholt](https://github.com/thomasaarholt))
- Andrea Maiani ([@maiani](https://github.com/maiani))
- Juan Daniel Torres ([@juandaanieel](https://github.com/juandaanieel))
- Davide Sandonà ([@juandaanieel](https://github.com/Davide-sd))
- Pieter Eendebak ([@eendebakpt](https://github.com/eendebakpt))
167 changes: 167 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<!-- badges-start -->

# ![logo](https://adaptive.readthedocs.io/en/latest/_static/logo.png) adaptive

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/python-adaptive/adaptive/master?filepath=example-notebook.ipynb)
[![Conda](https://img.shields.io/badge/install%20with-conda-green.svg)](https://anaconda.org/conda-forge/adaptive)
[![Coverage](https://img.shields.io/codecov/c/github/python-adaptive/adaptive)](https://codecov.io/gh/python-adaptive/adaptive)
[![DOI](https://img.shields.io/badge/doi-10.5281%2Fzenodo.1182437-blue.svg)](https://doi.org/10.5281/zenodo.1182437)
[![Documentation](https://readthedocs.org/projects/adaptive/badge/?version=latest)](https://adaptive.readthedocs.io/en/latest/?badge=latest)
[![Downloads](https://img.shields.io/conda/dn/conda-forge/adaptive.svg)](https://anaconda.org/conda-forge/adaptive)
[![GitHub](https://img.shields.io/github/stars/python-adaptive/adaptive.svg?style=social)](https://github.com/python-adaptive/adaptive/stargazers)
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/python-adaptive/adaptive)
[![Pipeline-status](https://dev.azure.com/python-adaptive/adaptive/_apis/build/status/python-adaptive.adaptive?branchName=master)](https://dev.azure.com/python-adaptive/adaptive/_build/latest?definitionId=6?branchName=master)
[![PyPI](https://img.shields.io/pypi/v/adaptive.svg)](https://pypi.python.org/pypi/adaptive)

> *Adaptive*: parallel active learning of mathematical functions.

<!-- badges-end -->

<!-- summary-start -->

`adaptive` is an open-source Python library designed to make adaptive parallel function evaluation simple. With `adaptive` you just supply a function with its bounds, and it will be evaluated at the “best” points in parameter space, rather than unnecessarily computing *all* points on a dense grid.
With just a few lines of code you can evaluate functions on a computing cluster, live-plot the data as it returns, and fine-tune the adaptive sampling algorithm.

`adaptive` excels on computations where each function evaluation takes *at least* ≈50ms due to the overhead of picking potentially interesting points.

Run the `adaptive` example notebook [live on Binder](https://mybinder.org/v2/gh/python-adaptive/adaptive/master?filepath=example-notebook.ipynb) to see examples of how to use `adaptive` or visit the [tutorial on Read the Docs](https://adaptive.readthedocs.io/en/latest/tutorial/tutorial.html).

<!-- summary-end -->

## Implemented algorithms

The core concept in `adaptive` is that of a *learner*.
A *learner* samples a function at the best places in its parameter space to get maximum “information” about the function.
As it evaluates the function at more and more points in the parameter space, it gets a better idea of where the best places are to sample next.

Of course, what qualifies as the “best places” will depend on your application domain! `adaptive` makes some reasonable default choices, but the details of the adaptive sampling are completely customizable.

The following learners are implemented:

<!-- not-in-documentation-start -->

- `Learner1D`, for 1D functions `f: ℝ → ℝ^N`,
- `Learner2D`, for 2D functions `f: ℝ^2 → ℝ^N`,
- `LearnerND`, for ND functions `f: ℝ^N → ℝ^M`,
- `AverageLearner`, for random variables where you want to average the result over many evaluations,
- `AverageLearner1D`, for stochastic 1D functions where you want to estimate the mean value of the function at each point,
- `IntegratorLearner`, for when you want to intergrate a 1D function `f: ℝ → ℝ`.
- `BalancingLearner`, for when you want to run several learners at once, selecting the “best” one each time you get more points.

Meta-learners (to be used with other learners):

- `BalancingLearner`, for when you want to run several learners at once, selecting the “best” one each time you get more points,
- `DataSaver`, for when your function doesn't just return a scalar or a vector.

In addition to the learners, `adaptive` also provides primitives for running the sampling across several cores and even several machines, with built-in support for
[concurrent.futures](https://docs.python.org/3/library/concurrent.futures.html),
[mpi4py](https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html),
[loky](https://loky.readthedocs.io/en/stable/),
[ipyparallel](https://ipyparallel.readthedocs.io/en/latest/), and
[distributed](https://distributed.readthedocs.io/en/latest/).

## Examples

Adaptively learning a 1D function (the `gif` below) and live-plotting the process in a Jupyter notebook is as easy as

```python
from adaptive import notebook_extension, Runner, Learner1D

notebook_extension()


def peak(x, a=0.01):
return x + a**2 / (a**2 + x**2)


learner = Learner1D(peak, bounds=(-1, 1))
runner = Runner(learner, goal=lambda l: l.loss() < 0.01)
runner.live_info()
runner.live_plot()
```

<img src="https://user-images.githubusercontent.com/6897215/38739170-6ac7c014-3f34-11e8-9e8f-93b3a3a3d61b.gif" width='20%'> </img> <img src="https://user-images.githubusercontent.com/6897215/35219611-ac8b2122-ff73-11e7-9332-adffab64a8ce.gif" width='40%'> </img> <img src="https://user-images.githubusercontent.com/6897215/47256441-d6d53700-d480-11e8-8224-d1cc49dbdcf5.gif" width='20%'> </img>

<!-- not-in-documentation-end -->

## Installation

`adaptive` works with Python 3.7 and higher on Linux, Windows, or Mac, and provides optional extensions for working with the Jupyter/IPython Notebook.

The recommended way to install adaptive is using `conda`:

```bash
conda install -c conda-forge adaptive
```

`adaptive` is also available on PyPI:

```bash
pip install "adaptive[notebook]"
```

The `[notebook]` above will also install the optional dependencies for running `adaptive` inside a Jupyter notebook.

To use Adaptive in Jupyterlab, you need to install the following labextensions.

```bash
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install @pyviz/jupyterlab_pyviz
```

## Development

Clone the repository and run `pip install -e ".[notebook,testing,other]"` to add a link to the cloned repo into your Python path:

```bash
git clone [email protected]:python-adaptive/adaptive.git
cd adaptive
pip install -e ".[notebook,testing,other]"
```

We highly recommend using a Conda environment or a virtualenv to manage the versions of your installed packages while working on `adaptive`.

In order to not pollute the history with the output of the notebooks, please setup the git filter by executing

```bash
python ipynb_filter.py
```

in the repository.

We implement several other checks in order to maintain a consistent code style. We do this using [pre-commit](https://pre-commit.com), execute

```bash
pre-commit install
```

in the repository.

## Citing

If you used Adaptive in a scientific work, please cite it as follows.

```bib
@misc{Nijholt2019,
doi = {10.5281/zenodo.1182437},
author = {Bas Nijholt and Joseph Weston and Jorn Hoofwijk and Anton Akhmerov},
title = {\textit{Adaptive}: parallel active learning of mathematical functions},
publisher = {Zenodo},
year = {2019}
}
```

## Credits

We would like to give credits to the following people:

- Pedro Gonnet for his implementation of [CQUAD](https://www.gnu.org/software/gsl/manual/html_node/CQUAD-doubly_002dadaptive-integration.html), “Algorithm 4” as described in “Increasing the Reliability of Adaptive Quadrature Using Explicit Interpolants”, P. Gonnet, ACM Transactions on Mathematical Software, 37 (3), art. no. 26, 2010.
- Pauli Virtanen for his `AdaptiveTriSampling` script (no longer available online since SciPy Central went down) which served as inspiration for the `adaptive.Learner2D`.

<!-- credits-end -->

For general discussion, we have a [Gitter chat channel](https://gitter.im/python-adaptive/adaptive). If you find any bugs or have any feature suggestions please file a GitHub [issue](https://github.com/python-adaptive/adaptive/issues/new) or submit a [pull request](https://github.com/python-adaptive/adaptive/pulls).

<!-- references-start -->

<!-- references-end -->
Loading