diff --git a/adaptive/learner/triangulation.py b/adaptive/learner/triangulation.py index 4eb5952d5..03455e3b7 100644 --- a/adaptive/learner/triangulation.py +++ b/adaptive/learner/triangulation.py @@ -16,9 +16,9 @@ ones, square, subtract, + zeros, ) from numpy import sum as np_sum -from numpy import zeros from numpy.linalg import det as ndet from numpy.linalg import matrix_rank, norm, slogdet, solve diff --git a/docs/logo.py b/docs/logo.py index 7544b396e..384c71065 100644 --- a/docs/logo.py +++ b/docs/logo.py @@ -3,8 +3,8 @@ import holoviews import matplotlib.pyplot as plt -import numpy as np import matplotlib.tri as mtri +import numpy as np from PIL import Image, ImageDraw sys.path.insert(0, os.path.abspath("..")) # to get adaptive on the path diff --git a/docs/source/algorithms_and_examples.md b/docs/source/algorithms_and_examples.md index e5c532dc3..f517b504b 100644 --- a/docs/source/algorithms_and_examples.md +++ b/docs/source/algorithms_and_examples.md @@ -46,11 +46,13 @@ Click on the *Play* {fa}`play` button or move the sliders. :tags: [hide-cell] import itertools -import adaptive -from adaptive.learner.learner1D import uniform_loss, default_loss + import holoviews as hv import numpy as np +import adaptive +from adaptive.learner.learner1D import default_loss, uniform_loss + adaptive.notebook_extension() hv.output(holomap="scrubber") ``` diff --git a/docs/source/tutorial/tutorial.AverageLearner1D.md b/docs/source/tutorial/tutorial.AverageLearner1D.md index 799338f82..38c3c6353 100644 --- a/docs/source/tutorial/tutorial.AverageLearner1D.md +++ b/docs/source/tutorial/tutorial.AverageLearner1D.md @@ -1,14 +1,15 @@ --- -kernelspec: - name: python3 - display_name: python3 jupytext: text_representation: extension: .md format_name: myst - format_version: '0.13' - jupytext_version: 1.13.8 + format_version: 0.13 + jupytext_version: 1.14.5 +kernelspec: + display_name: python3 + name: python3 --- + # Tutorial {class}`~adaptive.AverageLearner1D` ```{note} @@ -23,9 +24,10 @@ import adaptive adaptive.notebook_extension() +from functools import partial + import holoviews as hv import numpy as np -from functools import partial ``` ## General use diff --git a/docs/source/tutorial/tutorial.BalancingLearner.md b/docs/source/tutorial/tutorial.BalancingLearner.md index b33a6f823..8e43259c3 100644 --- a/docs/source/tutorial/tutorial.BalancingLearner.md +++ b/docs/source/tutorial/tutorial.BalancingLearner.md @@ -24,10 +24,11 @@ import adaptive adaptive.notebook_extension() +import random +from functools import partial + import holoviews as hv import numpy as np -from functools import partial -import random ``` The balancing learner is a “meta-learner” that takes a list of learners. diff --git a/docs/source/tutorial/tutorial.Learner1D.md b/docs/source/tutorial/tutorial.Learner1D.md index de40a83d1..e5ffe491a 100644 --- a/docs/source/tutorial/tutorial.Learner1D.md +++ b/docs/source/tutorial/tutorial.Learner1D.md @@ -25,9 +25,10 @@ import adaptive adaptive.notebook_extension() -import numpy as np -from functools import partial import random +from functools import partial + +import numpy as np ``` ## scalar output: `f:ℝ → ℝ` @@ -41,8 +42,8 @@ offset = random.uniform(-0.5, 0.5) def f(x, offset=offset, wait=True): - from time import sleep from random import random + from time import sleep a = 0.01 if wait: @@ -155,8 +156,8 @@ To do this, you need to tell the learner to look at the curvature by specifying ```{code-cell} ipython3 from adaptive.learner.learner1D import ( curvature_loss_function, - uniform_loss, default_loss, + uniform_loss, ) curvature_loss = curvature_loss_function() diff --git a/docs/source/tutorial/tutorial.Learner2D.md b/docs/source/tutorial/tutorial.Learner2D.md index 7d0130fc6..babc27c39 100644 --- a/docs/source/tutorial/tutorial.Learner2D.md +++ b/docs/source/tutorial/tutorial.Learner2D.md @@ -20,11 +20,12 @@ Download the notebook in order to see the real behaviour. [^download] ```{code-cell} ipython3 :tags: [hide-cell] -import adaptive +from functools import partial + import holoviews as hv import numpy as np -from functools import partial +import adaptive adaptive.notebook_extension() ``` @@ -33,9 +34,10 @@ Besides 1D functions, we can also learn 2D functions: $f: ℝ^2 → ℝ$. ```{code-cell} ipython3 def ring(xy, wait=True): - import numpy as np - from time import sleep from random import random + from time import sleep + + import numpy as np if wait: sleep(random() / 10) diff --git a/docs/source/tutorial/tutorial.custom_loss.md b/docs/source/tutorial/tutorial.custom_loss.md index 222dc6306..f1d84cd3f 100644 --- a/docs/source/tutorial/tutorial.custom_loss.md +++ b/docs/source/tutorial/tutorial.custom_loss.md @@ -25,8 +25,8 @@ import adaptive adaptive.notebook_extension() # Import modules that are used in multiple cells -import numpy as np import holoviews as hv +import numpy as np ``` {class}`~adaptive.Learner1D` and {class}`~adaptive.Learner2D` both work on the principle of subdividing their domain into subdomains, and assigning a property to each subdomain, which we call the *loss*. @@ -137,7 +137,7 @@ def resolution_loss_function(min_distance=0, max_distance=1): because the total area is normalized to 1.""" def resolution_loss(ip): - from adaptive.learner.learner2D import default_loss, areas + from adaptive.learner.learner2D import areas, default_loss loss = default_loss(ip)