Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 11, 2024
1 parent 02e7449 commit c89002b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
10 changes: 6 additions & 4 deletions examples/dataclasses_for_parameters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
},
"outputs": [],
"source": [
"import dataclasses\n",
"import pathlib\n",
"\n",
"from zntrack import config\n",
"import znjson\n",
"import dataclasses\n",
"\n",
"from zntrack import config\n",
"\n",
"config.nb_name = \"dataclasses_for_parameters.ipynb\""
]
Expand Down Expand Up @@ -102,8 +103,9 @@
},
"outputs": [],
"source": [
"from zntrack import Node, zn, Project\n",
"import random"
"import random\n",
"\n",
"from zntrack import Node, Project, zn"
]
},
{
Expand Down
23 changes: 11 additions & 12 deletions examples/estimate_pi_with_mc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as patches\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import zntrack"
]
},
Expand All @@ -85,8 +86,7 @@
"outputs": [],
"source": [
"class MCPi(zntrack.Node):\n",
" \"\"\"\n",
" A class to study Monte Carlo sampling as applied to\n",
" \"\"\"A class to study Monte Carlo sampling as applied to\n",
" the computation of Pi.\n",
"\n",
" Attributes\n",
Expand All @@ -97,6 +97,7 @@
" Number of points in the circle\n",
" n_points : int\n",
" Total number of points.\n",
"\n",
" \"\"\"\n",
"\n",
" n_points: int = zntrack.zn.params()\n",
Expand All @@ -105,8 +106,7 @@
" n_circle_points = zntrack.zn.outs()\n",
"\n",
" def run(self):\n",
" \"\"\"\n",
" Draw N points from a normal distribution.\n",
" \"\"\"Draw N points from a normal distribution.\n",
"\n",
" N : int\n",
" Number of points to draw.\n",
Expand All @@ -115,20 +115,19 @@
" self._circle_points() # compute the number of points in the circle.\n",
"\n",
" def _circle_points(self):\n",
" \"\"\"\n",
" Compute the number of points in the circle.\n",
" \"\"\"Compute the number of points in the circle.\n",
" \"\"\"\n",
" radial_values = np.linalg.norm(self.coordinates, axis=1)\n",
" self.n_circle_points = len(list(filter(lambda x: x <= 1, radial_values)))\n",
"\n",
" def plot_image(self, axs=None):\n",
" \"\"\"\n",
" Plot the circle, square, and points.\n",
" \"\"\"Plot the circle, square, and points.\n",
"\n",
" Parameters\n",
" ----------\n",
" axs : mpl.axis\n",
" An axis object to plot to if desired.\n",
"\n",
" \"\"\"\n",
" circle = plt.Circle((0, 0), 1, fill=False)\n",
" square = patches.Rectangle((0, 0), 1, 1, fill=False)\n",
Expand All @@ -150,13 +149,13 @@
" plt.show()\n",
"\n",
" def plot_sampling(self, axs=None, show: bool = False):\n",
" \"\"\"\n",
" Plot the result of the sampling.\n",
" \"\"\"Plot the result of the sampling.\n",
"\n",
" Parameters\n",
" ----------\n",
" axs : mpl.axis\n",
" An axis object to plot to if desired.\n",
"\n",
" \"\"\"\n",
" coordinates = np.array(self.coordinates)\n",
" circle = plt.Circle((0, 0), 1, fill=False, linewidth=3, edgecolor=\"k\", zorder=10)\n",
Expand Down

0 comments on commit c89002b

Please sign in to comment.