Skip to content

Commit

Permalink
Merge pull request #126 from mrakitin/sty-black-jupyter
Browse files Browse the repository at this point in the history
STY: add `black` formatter for Jupyter notebooks
  • Loading branch information
mrakitin authored Jul 18, 2023
2 parents 12bee28 + 67a258e commit 76d11b9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ repos:
rev: 23.3.0
hooks:
- id: black
language_version: python3.10
- id: black-jupyter
language_version: python3.10
exclude: ^(.*\.py)
args: [--line-length=88]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
Expand Down
33 changes: 18 additions & 15 deletions docs/source/notebooks/elements.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"connection = SirepoBluesky(\"http://localhost:8000\")\n",
"\n",
"data, schema = connection.auth(\"srw\", \"00000002\")\n",
"classes, objects = create_classes(connection.data,\n",
" connection=connection)\n",
"classes, objects = create_classes(connection.data, connection=connection)\n",
"globals().update(**objects)\n",
"\n",
"aperture.horizontalSize.kind = \"hinted\"\n",
Expand Down Expand Up @@ -71,10 +70,13 @@
"nrows = int(np.ceil(num_frames / ncols))\n",
"\n",
"fig = plt.figure()\n",
"grid = ImageGrid(fig, (1, 2, ncols, nrows),\n",
" nrows_ncols=(nrows, ncols),\n",
" axes_pad=0.5,\n",
" aspect=False)\n",
"grid = ImageGrid(\n",
" fig,\n",
" (1, 2, ncols, nrows),\n",
" nrows_ncols=(nrows, ncols),\n",
" axes_pad=0.5,\n",
" aspect=False,\n",
")\n",
"\n",
"for ax, im in zip(grid, w9_image[:, ...]):\n",
" ax.imshow(im, aspect=\"auto\")"
Expand Down Expand Up @@ -103,12 +105,11 @@
"connection = SirepoBluesky(\"http://localhost:8000\")\n",
"\n",
"data, schema = connection.auth(\"shadow\", \"00000002\")\n",
"classes, objects = create_classes(connection.data,\n",
" connection=connection)\n",
"classes, objects = create_classes(connection.data, connection=connection)\n",
"globals().update(**objects)\n",
"\n",
"print(f\"Number of points before change: {data['models']['simulation']['npoint']}\")\n",
"data['models']['simulation']['npoint'] = 1000000\n",
"data[\"models\"][\"simulation\"][\"npoint\"] = 1000000\n",
"print(f\"Number of points after change: {data['models']['simulation']['npoint']}\")\n",
"aperture.horizontalSize.kind = \"hinted\"\n",
"w9.duration.kind = \"hinted\"\n",
Expand Down Expand Up @@ -136,10 +137,13 @@
"nrows = int(np.ceil(num_frames / ncols))\n",
"\n",
"fig = plt.figure()\n",
"grid = ImageGrid(fig, (1, 2, ncols, nrows),\n",
" nrows_ncols=(nrows, ncols),\n",
" axes_pad=0.5,\n",
" aspect=False)\n",
"grid = ImageGrid(\n",
" fig,\n",
" (1, 2, ncols, nrows),\n",
" nrows_ncols=(nrows, ncols),\n",
" axes_pad=0.5,\n",
" aspect=False,\n",
")\n",
"\n",
"for ax, im in zip(grid, w9_image[:, ...]):\n",
" ax.imshow(im, aspect=\"auto\")"
Expand Down Expand Up @@ -169,8 +173,7 @@
"\n",
"data, schema = connection.auth(\"shadow\", \"00000002\")\n",
"\n",
"classes, objects = create_classes(connection.data,\n",
" connection=connection)\n",
"classes, objects = create_classes(connection.data, connection=connection)\n",
"globals().update(**objects)\n",
"\n",
"bsr = BeamStatisticsReport(name=\"bsr\", connection=connection)\n",
Expand Down
17 changes: 11 additions & 6 deletions docs/source/notebooks/madx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@
"connection = SirepoBluesky(\"http://localhost:8000\")\n",
"\n",
"data, schema = connection.auth(\"madx\", \"00000002\")\n",
"classes, objects = create_classes(connection.data,\n",
" connection=connection,\n",
" extra_model_fields=[\"rpnVariables\", \"commands\"])\n",
"classes, objects = create_classes(\n",
" connection.data,\n",
" connection=connection,\n",
" extra_model_fields=[\"rpnVariables\", \"commands\"],\n",
")\n",
"globals().update(**objects)\n",
"\n",
"madx_flyer = MADXFlyer(connection=connection,\n",
" root_dir=\"/tmp/sirepo-bluesky-data\",\n",
" report=\"elementAnimation250-20\")\n",
"madx_flyer = MADXFlyer(\n",
" connection=connection,\n",
" root_dir=\"/tmp/sirepo-bluesky-data\",\n",
" report=\"elementAnimation250-20\",\n",
")\n",
"\n",
"(uid1,) = RE(bp.fly([madx_flyer]))\n",
"hdr1 = db[uid1]\n",
Expand All @@ -68,6 +72,7 @@
" yield from bps.mv(parameter.value, value)\n",
" return (yield from bp.fly([madx_flyer]))\n",
"\n",
"\n",
"(uid2,) = RE(madx_plan())\n",
"hdr2 = db[uid2]\n",
"tbl2 = hdr2.table(stream_name=\"madx_flyer\", fill=True)\n",
Expand Down

0 comments on commit 76d11b9

Please sign in to comment.