Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Mar 25, 2024
1 parent 10b2983 commit 94701b9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 24 deletions.
12 changes: 6 additions & 6 deletions docs/examples/complete.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@
"# Let's see what kind of particles we have in the simulation\n",
"counts = particles[\"pdgid\"].value_counts()\n",
"counts.index = counts.index.map(\n",
" lambda pid: f\"{Particle.from_pdgid(pid).name} ({pid})\"\n",
" if pid != 0\n",
" else \"unknown (0)\"\n",
" lambda pid: (\n",
" f\"{Particle.from_pdgid(pid).name} ({pid})\" if pid != 0 else \"unknown (0)\"\n",
" )\n",
")\n",
"counts.plot(kind=\"bar\", log=True)\n",
"\n",
Expand Down Expand Up @@ -293,9 +293,9 @@
"\n",
"counts = sel.mother_pdgid_cleaned.value_counts()\n",
"counts.index = counts.index.map(\n",
" lambda pid: f\"{Particle.from_pdgid(pid).name} ({pid})\"\n",
" if pid != 0\n",
" else \"unknown (0)\"\n",
" lambda pid: (\n",
" f\"{Particle.from_pdgid(pid).name} ({pid})\" if pid != 0 else \"unknown (0)\"\n",
" )\n",
")\n",
"counts.plot(kind=\"bar\", log=True)\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/plot_spectrum.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@
"\n",
"counts = sel.mother_pdgid_cleaned.value_counts()\n",
"counts.index = counts.index.map(\n",
" lambda pid: f\"{Particle.from_pdgid(pid).name} ({pid})\"\n",
" if pid != 0\n",
" else \"unknown (0)\"\n",
" lambda pid: (\n",
" f\"{Particle.from_pdgid(pid).name} ({pid})\" if pid != 0 else \"unknown (0)\"\n",
" )\n",
")\n",
"counts.plot(kind=\"bar\", log=True)\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions panama/_nbstreamreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Only to be used internally.
Adapted from http://eyalarubas.com/python-subproc-nonblock.html
"""

from __future__ import annotations

from queue import Empty, Queue
Expand Down
1 change: 1 addition & 0 deletions panama/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Some constants used across multiple modules
"""

from particle import PDGID, Particle

D0_LIFETIME = Particle.from_name("D0").lifetime
Expand Down
7 changes: 4 additions & 3 deletions panama/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Functions to use to determine if a particle is prompt or not,
using multiple different definitions.
"""

from __future__ import annotations

from math import inf
Expand Down Expand Up @@ -60,9 +61,9 @@ def add_cleaned_mother_cols(df_particles: pd.DataFrame) -> None:
if "mother_lifetime_cleaned" not in df_particles:
pdgids = df_particles["mother_pdgid_cleaned"].unique()
lifetimes = {
pdgid: Particle.from_pdgid(pdgid).lifetime
if pdgid != PDGID_ERROR_VAL
else inf
pdgid: (
Particle.from_pdgid(pdgid).lifetime if pdgid != PDGID_ERROR_VAL else inf
)
for pdgid in pdgids
}
for pdgid in lifetimes:
Expand Down
24 changes: 15 additions & 9 deletions panama/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,11 @@ def read_DAT(
# the use of pd.NA is currently experimental in Int64 type columns
corsikaids = df_particles["corsikaid"].unique()
pdg_map = {
corsikaid: int(Corsika7ID(corsikaid).to_pdgid())
if Corsika7ID(corsikaid).is_particle()
else PDGID_ERROR_VAL # This will be our error value
corsikaid: (
int(Corsika7ID(corsikaid).to_pdgid())
if Corsika7ID(corsikaid).is_particle()
else PDGID_ERROR_VAL
) # This will be our error value
for corsikaid in corsikaids
}
df_particles["pdgid"] = (
Expand Down Expand Up @@ -381,9 +383,11 @@ def add_mother_columns(
df_particles.loc[~df_particles["has_mother"], f"mother_{name}"] = error_val

has_charm = {
pdgid: "c" in Particle.from_pdgid(pdgid).quarks.lower()
if pdgid != PDGID_ERROR_VAL
else False
pdgid: (
"c" in Particle.from_pdgid(pdgid).quarks.lower()
if pdgid != PDGID_ERROR_VAL
else False
)
for pdgid in pdgids
}

Expand All @@ -397,9 +401,11 @@ def add_mother_columns(
lifetimes[pdgid] = 0

is_resonance = {
pdgid: "*" in Particle.from_pdgid(pdgid).name
if pdgid != PDGID_ERROR_VAL
else False
pdgid: (
"*" in Particle.from_pdgid(pdgid).name
if pdgid != PDGID_ERROR_VAL
else False
)
for pdgid in pdgids
}

Expand Down
1 change: 1 addition & 0 deletions panama/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Classes handling the parallel execution of CORSIKA7 processes.
"""

from __future__ import annotations

import io
Expand Down
7 changes: 4 additions & 3 deletions panama/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
are given in units of :math:`(\mathrm{m^2}\ \mathrm{s}\ \mathrm{sr}\ \mathrm{GeV})^{-1}`.
""" # noqa: W605

from __future__ import annotations

from typing import Any
Expand Down Expand Up @@ -150,9 +151,9 @@ def add_weight_prompt(
df.sort_index(inplace=True)

df[weight_col_name] = 1.0
df.loc[
df[is_prompt_col_name] == True, weight_col_name # noqa: E712
] = prompt_factor
df.loc[df[is_prompt_col_name] == True, weight_col_name] = ( # noqa: E712
prompt_factor
)


def add_weight_prompt_per_event(
Expand Down

0 comments on commit 94701b9

Please sign in to comment.