Skip to content

Commit

Permalink
Run pre-commit filters on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Sep 19, 2022
1 parent 09e4f35 commit 202d22a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions example-notebook.ipynb
Expand Up @@ -27,11 +27,12 @@
"\n",
"adaptive.notebook_extension()\n",
"\n",
"import random\n",
"from functools import partial\n",
"\n",
"# Import modules that are used in multiple cells\n",
"import holoviews as hv\n",
"import numpy as np\n",
"from functools import partial\n",
"import random"
"import numpy as np"
]
},
{
Expand Down Expand Up @@ -60,15 +61,15 @@
"\n",
"\n",
"def peak(x, offset=offset, wait=True):\n",
" from time import sleep\n",
" from random import random\n",
" from time import sleep\n",
"\n",
" a = 0.01\n",
" if wait:\n",
" # we pretend that this is a slow function\n",
" sleep(random())\n",
"\n",
" return x + a**2 / (a**2 + (x - offset)**2)"
" return x + a**2 / (a**2 + (x - offset) ** 2)"
]
},
{
Expand Down Expand Up @@ -173,16 +174,17 @@
"outputs": [],
"source": [
"def ring(xy, wait=True):\n",
" import numpy as np\n",
" from time import sleep\n",
" from random import random\n",
" from time import sleep\n",
"\n",
" import numpy as np\n",
"\n",
" if wait:\n",
" # we pretend that this is a slow function\n",
" sleep(random() / 10)\n",
" x, y = xy\n",
" a = 0.2\n",
" return x + np.exp(-((x**2 + y**2 - 0.75**2)**2) / a**4)\n",
" return x + np.exp(-((x**2 + y**2 - 0.75**2) ** 2) / a**4)\n",
"\n",
"\n",
"learner = adaptive.Learner2D(ring, bounds=[(-1, 1), (-1, 1)])"
Expand Down Expand Up @@ -223,7 +225,7 @@
"# Create a learner and add data on homogeneous grid, so that we can plot it\n",
"learner2 = adaptive.Learner2D(ring, bounds=learner.bounds)\n",
"n = int(learner.npoints**0.5)\n",
"xs, ys = [np.linspace(*bounds, n) for bounds in learner.bounds]\n",
"xs, ys = (np.linspace(*bounds, n) for bounds in learner.bounds)\n",
"xys = list(itertools.product(xs, ys))\n",
"zs = [ring(xy, wait=False) for xy in xys]\n",
"learner2.tell_many(xys, zs)\n",
Expand Down Expand Up @@ -316,7 +318,7 @@
"source": [
"def noisy_peak(seed_x, sigma=0, peak_width=0.05, offset=-0.5):\n",
" seed, x = seed_x\n",
" y = x**3 - x + 3 * peak_width**2 / (peak_width**2 + (x - offset)**2)\n",
" y = x**3 - x + 3 * peak_width**2 / (peak_width**2 + (x - offset) ** 2)\n",
" rng = np.random.RandomState(int(seed))\n",
" noise = rng.normal(scale=sigma)\n",
" return y + noise"
Expand Down Expand Up @@ -568,7 +570,7 @@
"def sphere(xyz):\n",
" x, y, z = xyz\n",
" a = 0.4\n",
" return x + z**2 + np.exp(-((x**2 + y**2 + z**2 - 0.75**2)**2) / a**4)\n",
" return x + z**2 + np.exp(-((x**2 + y**2 + z**2 - 0.75**2) ** 2) / a**4)\n",
"\n",
"\n",
"learner = adaptive.LearnerND(sphere, bounds=[(-1, 1), (-1, 1), (-1, 1)])\n",
Expand Down Expand Up @@ -817,7 +819,7 @@
"source": [
"def h(x, offset=0):\n",
" a = 0.01\n",
" return x + a**2 / (a**2 + (x - offset)**2)\n",
" return x + a**2 / (a**2 + (x - offset) ** 2)\n",
"\n",
"\n",
"learners = [\n",
Expand Down

0 comments on commit 202d22a

Please sign in to comment.