Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: add black formatter for Jupyter notebooks #126

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=78]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
Expand Down
41 changes: 24 additions & 17 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,13 +105,16 @@
"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",
"print(f\"Number of points after change: {data['models']['simulation']['npoint']}\")\n",
"print(\n",
" f\"Number of points before change: {data['models']['simulation']['npoint']}\"\n",
")\n",
"data[\"models\"][\"simulation\"][\"npoint\"] = 1000000\n",
"print(\n",
" f\"Number of points after change: {data['models']['simulation']['npoint']}\"\n",
")\n",
"aperture.horizontalSize.kind = \"hinted\"\n",
"w9.duration.kind = \"hinted\"\n",
"\n",
Expand All @@ -136,10 +141,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 +177,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
Loading