You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 738e352
Browse filesBrowse the repository at this point in the historyBrowse files
Address the README review: runnable script example, scope, executors
- Make the script example self-contained (it used peak from the
notebook example) and show to_numpy() in it.
- Say that adaptive is meant for functions of a few parameters.
- Explain what the loss function is and point to the built-in
alternatives and the custom loss tutorial.
- Say that the runners use all local cores by default, how to pass
another executor, and link the parallelism tutorial.
- Install with plain pip install adaptive; the [notebook] extra adds
live plotting and pandas for to_dataframe().
- Development: add the test command; the notebook git filter needs
nbconvert and only matters for example-notebook.ipynb.
- Move the animation caption into the summary snippet, so the docs
home page shows it too; label the conda downloads badge; fix the
CQUAD link.
- Parallelism tutorial: drop the stale claim that Windows defaults to
distributed.Client; loky is the default everywhere.
@@ -20,13 +20,14 @@ You supply a function and its bounds, and `adaptive` evaluates it at the "best"
20
20
With a few lines of code you can run the evaluations on a computing cluster, live-plot the data as it comes in, and fine-tune the sampling algorithm.
21
21
22
22
`adaptive` works best when each function evaluation takes *at least* ≈50 ms, because picking the next points has some overhead.
23
+
It is meant for functions of a few parameters: with more dimensions, `LearnerND` quickly becomes slower and less effective.
23
24
24
25
Try the example notebook [on Binder](https://mybinder.org/v2/gh/python-adaptive/adaptive/main?filepath=example-notebook.ipynb) or read the [tutorial](https://adaptive.readthedocs.io/en/latest/tutorial/tutorial/).
25
26
26
-
<!-- --8<-- [end:summary] -->
27
-
28
27
With the same number of points, adaptive sampling resolves features that a homogeneous grid misses:
29
28
29
+
<!-- --8<-- [end:summary] -->
30
+
30
31
<palign="center">
31
32
<imgsrc="https://raw.githubusercontent.com/python-adaptive/adaptive/main/docs/_static/readme/learner1d.gif"width="43%"alt="Learner1D: homogeneous grid versus adaptive sampling of a sharp peak">
32
33
<imgsrc="https://raw.githubusercontent.com/python-adaptive/adaptive/main/docs/_static/readme/learner2d.gif"width="36%"alt="Learner2D: homogeneous grid versus adaptive triangulation of a ring">
@@ -59,11 +60,17 @@ In a script, use `BlockingRunner`, which returns once the goal is reached:
59
60
```python
60
61
from adaptive import BlockingRunner, Learner1D
61
62
63
+
64
+
defpeak(x, a=0.01):
65
+
return x + a**2/ (a**2+ x**2)
66
+
67
+
62
68
learner = Learner1D(peak, bounds=(-1, 1))
63
69
BlockingRunner(learner, loss_goal=0.01)
70
+
data = learner.to_numpy() # array with columns x, y
64
71
```
65
72
66
-
Afterwards, `learner.to_numpy()` returns the data as a NumPy array, and `learner.to_dataframe()` as a pandas DataFrame.
73
+
`learner.to_dataframe()` returns the same data as a pandas DataFrame (pandas comes with the `[notebook]` extra).
67
74
68
75
<!-- --8<-- [start:implemented-algorithms] -->
69
76
@@ -74,7 +81,8 @@ A learner samples a function at the points in its parameter space that tell it t
74
81
As it evaluates more points, it gets a better idea of where to sample next.
75
82
76
83
What the "best" points are depends on your application.
77
-
`adaptive` makes reasonable default choices, but the details of the sampling are completely customizable.
84
+
Each learner ranks candidate points with a *loss function*.
85
+
The default losses put more points where the function changes quickly; you can pass a built-in alternative, such as `curvature_loss_function()` or `resolution_loss_function()`, or write your own (see the [custom loss tutorial](https://adaptive.readthedocs.io/en/latest/tutorial/tutorial.custom_loss/)).
78
86
79
87
The following learners are implemented:
80
88
@@ -100,6 +108,9 @@ In addition to the learners, `adaptive` provides primitives for running the samp
100
108
[ipyparallel](https://ipyparallel.readthedocs.io/en/latest/), and
By default, both runners evaluate the function in parallel on all cores of the local machine, using loky.
112
+
To use one of the others, pass it as `executor`, for example `Runner(learner, executor=distributed.Client())`; the [parallelism tutorial](https://adaptive.readthedocs.io/en/latest/tutorial/tutorial.parallelism/) has an example for each.
The `[notebook]` extra installs the dependencies for live plotting and widgets in JupyterLab and Jupyter Notebook; no Jupyter extensions are needed.
132
+
Add the `[notebook]` extra (`pip install "adaptive[notebook]"`) for live plotting and widgets in JupyterLab and Jupyter Notebook, and for `to_dataframe()`; no Jupyter extensions are needed.
We recommend a virtual environment, for example with [uv](https://docs.astral.sh/uv/) (`uv sync --extra notebook --extra test --extra other`) or Conda.
145
156
146
-
To avoid polluting the history with notebook output, set up the git filter by running
147
-
148
-
```bash
149
-
python ipynb_filter.py
150
-
```
151
-
152
-
in the repository.
153
-
154
157
We use [pre-commit](https://pre-commit.com) for a consistent code style; install the hooks with
155
158
156
159
```bash
157
160
pre-commit install
158
161
```
159
162
163
+
Run the tests with `pytest`.
164
+
165
+
If you edit `example-notebook.ipynb`, install `nbconvert` and run `python ipynb_filter.py` once, so git strips the notebook output on commit.
166
+
160
167
### Building the documentation
161
168
162
169
The documentation is built with [Zensical](https://zensical.org).
@@ -190,7 +197,7 @@ The algorithms are described in more detail in a [draft paper](https://github.co
190
197
191
198
We would like to give credits to the following people:
192
199
193
-
- 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.
200
+
- Pedro Gonnet for his implementation of [CQUAD](https://www.gnu.org/software/gsl/doc/html/integration.html#cquad-doubly-adaptive-integration), "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.
194
201
- Pauli Virtanen for his `AdaptiveTriSampling` script (no longer available online since SciPy Central went down), which served as inspiration for `adaptive.Learner2D`.
0 commit comments