|
490 | 490 | "\n",
|
491 | 491 | "print(\n",
|
492 | 492 | " f\"The integral value is {learner.igral} \"\n",
|
493 |
| - " f\"with a corresponding error of {learner.err}\"\n", |
| 493 | + " f\"with a corresponding error of {learner.err}\",\n", |
494 | 494 | ")\n",
|
495 | 495 | "learner.plot()"
|
496 | 496 | ]
|
|
683 | 683 | "\n",
|
684 | 684 | "\n",
|
685 | 685 | "learner = adaptive.Learner1D(\n",
|
686 |
| - " f_divergent_1d, (-1, 1), loss_per_interval=uniform_sampling_1d\n", |
| 686 | + " f_divergent_1d,\n", |
| 687 | + " (-1, 1),\n", |
| 688 | + " loss_per_interval=uniform_sampling_1d,\n", |
687 | 689 | ")\n",
|
688 | 690 | "runner = adaptive.BlockingRunner(learner, loss_goal=0.01)\n",
|
689 | 691 | "learner.plot().select(y=(0, 10000))"
|
|
755 | 757 | "source": [
|
756 | 758 | "def resolution_loss(ip, min_distance=0, max_distance=1):\n",
|
757 | 759 | " \"\"\"min_distance and max_distance should be in between 0 and 1\n",
|
758 |
| - " because the total area is normalized to 1.\"\"\"\n", |
759 |
| - "\n", |
| 760 | + " because the total area is normalized to 1.\n", |
| 761 | + " \"\"\"\n", |
760 | 762 | " from adaptive.learner.learner2D import areas, deviations\n",
|
761 | 763 | "\n",
|
762 | 764 | " A = areas(ip)\n",
|
|
773 | 775 | " loss = np.sqrt(A) * dev + A\n",
|
774 | 776 | "\n",
|
775 | 777 | " # Setting areas with a small area to zero such that they won't be chosen again\n",
|
776 |
| - " loss[A < min_distance**2] = 0\n", |
| 778 | + " loss[min_distance**2 > A] = 0\n", |
777 | 779 | "\n",
|
778 | 780 | " # Setting triangles that have a size larger than max_distance to infinite loss\n",
|
779 |
| - " loss[A > max_distance**2] = np.inf\n", |
| 781 | + " loss[max_distance**2 < A] = np.inf\n", |
780 | 782 | "\n",
|
781 | 783 | " return loss\n",
|
782 | 784 | "\n",
|
|
874 | 876 | "}\n",
|
875 | 877 | "\n",
|
876 | 878 | "learner = adaptive.BalancingLearner.from_product(\n",
|
877 |
| - " jacobi, adaptive.Learner1D, {\"bounds\": (0, 1)}, combos\n", |
| 879 | + " jacobi,\n", |
| 880 | + " adaptive.Learner1D,\n", |
| 881 | + " {\"bounds\": (0, 1)},\n", |
| 882 | + " combos,\n", |
878 | 883 | ")\n",
|
879 | 884 | "\n",
|
880 | 885 | "runner = adaptive.BlockingRunner(learner, loss_goal=0.01)\n",
|
|
1249 | 1254 | "runner = adaptive.Runner(learner, npoints_goal=100)\n",
|
1250 | 1255 | "\n",
|
1251 | 1256 | "runner.start_periodic_saving(\n",
|
1252 |
| - " save_kwargs={\"fname\": \"data/periodic_example.p\"}, interval=6\n", |
| 1257 | + " save_kwargs={\"fname\": \"data/periodic_example.p\"},\n", |
| 1258 | + " interval=6,\n", |
1253 | 1259 | ")\n",
|
1254 | 1260 | "\n",
|
1255 | 1261 | "runner.live_info()"
|
|
1487 | 1493 | "\n",
|
1488 | 1494 | "learner = adaptive.Learner1D(will_raise, (-1, 1))\n",
|
1489 | 1495 | "runner = adaptive.Runner(\n",
|
1490 |
| - " learner\n", |
| 1496 | + " learner,\n", |
1491 | 1497 | ") # without 'goal' the runner will run forever unless cancelled\n",
|
1492 | 1498 | "runner.live_info()\n",
|
1493 | 1499 | "runner.live_plot()"
|
|
0 commit comments