Skip to content

Commit 9ac905d

Browse files
committed
Instruct pre-commit to ignore Rust files and release workflow
1 parent a7c717a commit 9ac905d

File tree

3 files changed

+68
-25
lines changed

3 files changed

+68
-25
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ repos:
55
rev: v4.6.0
66
hooks:
77
- id: trailing-whitespace
8-
exclude: ^pineappl_cli/tests/
8+
# `.rs` files are taken care of by `cargo fmt`
9+
# `.github/workflows/release.yml` contains vital spaces
10+
exclude: ^(.*\.rs|\.github/workflows/release.yml)$
911
- id: end-of-file-fixer
1012
- id: check-merge-conflict
1113
- repo: https://github.com/astral-sh/ruff-pre-commit

pineappl_py/docs/source/advanced.ipynb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"\n",
123123
"np.random.seed(1234567890)\n",
124124
"\n",
125+
"\n",
125126
"def hadronic_ps_gen(\n",
126127
" mmin: float, mmax: float\n",
127128
") -> Tuple[float, float, float, float, float, float]:\n",
@@ -156,7 +157,7 @@
156157
" r1 = np.random.uniform()\n",
157158
" r2 = np.random.uniform()\n",
158159
" r3 = np.random.uniform()\n",
159-
" \n",
160+
"\n",
160161
" # generate partonic x1 and x2\n",
161162
" tau0 = smin / smax\n",
162163
" tau = pow(tau0, r1)\n",
@@ -256,6 +257,7 @@
256257
"source": [
257258
"import pineappl\n",
258259
"\n",
260+
"\n",
259261
"def fill_grid(grid: pineappl.grid.Grid, calls: int):\n",
260262
" \"\"\"Fill grid with points.\"\"\"\n",
261263
"\n",
@@ -293,7 +295,7 @@
293295
" weight = jacobian * photon_photon_matrix_element(s, u, t)\n",
294296
" # set factorization and renormalization scale to (roughly) the Z-boson mass\n",
295297
" q2 = 90.0 * 90.0\n",
296-
" \n",
298+
"\n",
297299
" # fill the interpolation grid\n",
298300
" grid.fill(x1, x2, q2, 0, np.abs(yll), 0, weight)"
299301
]
@@ -367,7 +369,7 @@
367369
"grid = generate_grid(1000000)\n",
368370
"\n",
369371
"# perform convolution with PDFs: this performs the x1 and x2 integrals\n",
370-
"# of the partonic cross sections with the PDFs as given by our master \n",
372+
"# of the partonic cross sections with the PDFs as given by our master\n",
371373
"# formula\n",
372374
"pdf = lhapdf.mkPDF(\"NNPDF31_nnlo_as_0118_luxqed\", 0)\n",
373375
"bins = grid.convolve_with_one(2212, pdf.xfxQ2, pdf.alphasQ2)"
@@ -411,8 +413,10 @@
411413
"nbins = np.append(bins, bins[-1])\n",
412414
"edges = np.arange(0.0, 2.4, 0.1)\n",
413415
"\n",
414-
"ax.step(edges, nbins, where='post', color=\"C1\")\n",
415-
"plt.fill_between(np.arange(0.0, 2.4, 0.1), nbins, step=\"post\", color=\"C1\", alpha=0.2)\n",
416+
"ax.step(edges, nbins, where=\"post\", color=\"C1\")\n",
417+
"plt.fill_between(\n",
418+
" np.arange(0.0, 2.4, 0.1), nbins, step=\"post\", color=\"C1\", alpha=0.2\n",
419+
")\n",
416420
"ax.set_xlabel(\"$|y_{\\ell\\ell}|$\")\n",
417421
"ax.set_ylabel(\"$\\mathrm{d} \\sigma / \\mathrm{d} |y_{\\ell\\ell}|$ [pb]\")\n",
418422
"ax.grid(True, alpha=0.5)\n",

pineappl_py/docs/source/introduction.ipynb

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"# We first need to load the PDF set with LHAPDF\n",
126126
"import lhapdf\n",
127127
"import numpy as np\n",
128+
"\n",
128129
"# `Polars` is a better alternative to Pandas (written in Rust!)\n",
129130
"import polars as pl\n",
130131
"\n",
@@ -188,10 +189,12 @@
188189
],
189190
"source": [
190191
"predictions = grid.convolve_with_one(2212, pdf.xfxQ2, pdf.alphasQ2)\n",
191-
"df_preds = pl.DataFrame({\n",
192-
" \"bins\": range(predictions.size),\n",
193-
" \"predictions\": predictions,\n",
194-
"})\n",
192+
"df_preds = pl.DataFrame(\n",
193+
" {\n",
194+
" \"bins\": range(predictions.size),\n",
195+
" \"predictions\": predictions,\n",
196+
" }\n",
197+
")\n",
195198
"df_preds"
196199
]
197200
},
@@ -231,17 +234,44 @@
231234
"import matplotlib.pyplot as plt\n",
232235
"\n",
233236
"# Experimental central values as provided by HepData\n",
234-
"data_central = np.array([\n",
235-
" 1223.0, 3263.0, 4983.0, 6719.0, 8051.0, 8967.0, 9561.0, 9822.0, 9721.0, 9030.0, 7748.0, 6059.0, 4385.0, 2724.0, 1584.0, 749.0, 383.0, 11.0\n",
236-
"])\n",
237+
"data_central = np.array(\n",
238+
" [\n",
239+
" 1223.0,\n",
240+
" 3263.0,\n",
241+
" 4983.0,\n",
242+
" 6719.0,\n",
243+
" 8051.0,\n",
244+
" 8967.0,\n",
245+
" 9561.0,\n",
246+
" 9822.0,\n",
247+
" 9721.0,\n",
248+
" 9030.0,\n",
249+
" 7748.0,\n",
250+
" 6059.0,\n",
251+
" 4385.0,\n",
252+
" 2724.0,\n",
253+
" 1584.0,\n",
254+
" 749.0,\n",
255+
" 383.0,\n",
256+
" 11.0,\n",
257+
" ]\n",
258+
")\n",
237259
"\n",
238260
"# Normalization for each bin. See Section below for more details.\n",
239-
"bin_norm = np.array([0.125 for _ in range(predictions.size - 2)] + [0.250, 0.250])\n",
261+
"bin_norm = np.array(\n",
262+
" [0.125 for _ in range(predictions.size - 2)] + [0.250, 0.250]\n",
263+
")\n",
240264
"\n",
241265
"fig, ax = plt.subplots(figsize=(5.6, 3.9))\n",
242266
"# Factor of `1e3` takes into account the unit conversion into `fb`\n",
243-
"ax.plot(df_preds[\"bins\"], 1e3 * bin_norm * df_preds[\"predictions\"], 's', markersize=8, label=\"theory\")\n",
244-
"ax.plot(df_preds[\"bins\"], data_central, 'o', markersize=8, label=\"data\")\n",
267+
"ax.plot(\n",
268+
" df_preds[\"bins\"],\n",
269+
" 1e3 * bin_norm * df_preds[\"predictions\"],\n",
270+
" \"s\",\n",
271+
" markersize=8,\n",
272+
" label=\"theory\",\n",
273+
")\n",
274+
"ax.plot(df_preds[\"bins\"], data_central, \"o\", markersize=8, label=\"data\")\n",
245275
"ax.grid(True, alpha=0.5)\n",
246276
"ax.set_yscale(\"log\")\n",
247277
"ax.set_xlabel(\"bins\")\n",
@@ -417,10 +447,7 @@
417447
"for idx, o in enumerate(grid.orders()):\n",
418448
" orders.append(o.as_tuple())\n",
419449
"\n",
420-
"df_orders = pl.DataFrame(\n",
421-
" np.array(orders),\n",
422-
" schema=[\"as\", \"a\", \"lf\", \"lr\"]\n",
423-
")\n",
450+
"df_orders = pl.DataFrame(np.array(orders), schema=[\"as\", \"a\", \"lf\", \"lr\"])\n",
424451
"df_orders.with_row_index()"
425452
]
426453
},
@@ -506,10 +533,18 @@
506533
"# an associated bin normalization.\n",
507534
"df = pl.DataFrame({})\n",
508535
"for bin_dim in range(bin_dims):\n",
509-
" df = pl.concat([df,pl.DataFrame({\n",
510-
" f\"dim {bin_dim} left\": grid.bin_left(bin_dim),\n",
511-
" f\"dim {bin_dim} right\": grid.bin_right(bin_dim),\n",
512-
" })],how=\"vertical\",)\n",
536+
" df = pl.concat(\n",
537+
" [\n",
538+
" df,\n",
539+
" pl.DataFrame(\n",
540+
" {\n",
541+
" f\"dim {bin_dim} left\": grid.bin_left(bin_dim),\n",
542+
" f\"dim {bin_dim} right\": grid.bin_right(bin_dim),\n",
543+
" }\n",
544+
" ),\n",
545+
" ],\n",
546+
" how=\"vertical\",\n",
547+
" )\n",
513548
"df"
514549
]
515550
},
@@ -670,7 +705,9 @@
670705
],
671706
"source": [
672707
"# Load our modified grids\n",
673-
"grid_nrm = pineappl.grid.Grid.read(\"./LHCB_DY_8TEV_custom_normalizations.pineappl.lz4\")\n",
708+
"grid_nrm = pineappl.grid.Grid.read(\n",
709+
" \"./LHCB_DY_8TEV_custom_normalizations.pineappl.lz4\"\n",
710+
")\n",
674711
"df_nbins = pl.DataFrame({\"bin normalization\": grid_nrm.bin_normalizations()})\n",
675712
"df_nbins.with_row_index()"
676713
]

0 commit comments

Comments
 (0)