Skip to content

Commit

Permalink
Make it simple for MyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardo-rodrigues committed Aug 9, 2024
1 parent f4b2d7b commit aa66055
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/decaylanguage/dec/dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,33 +954,35 @@ def print_decay_modes(

dms = self._find_decay_modes(mother)

maxLength = 0
max_length: int = 0
ls = []
for dm in dms:
dmdict = self._decay_mode_details(dm, display_photos_keyword)
modelParsList = [str(i) for i in dmdict["model_params"]]
model_params = "" if modelParsList == [] else " ".join(modelParsList)
decayChain = " ".join(list(dmdict["fs"]))
if len(decayChain) > maxLength:
maxLength = len(decayChain)
ls.append((dmdict["bf"], decayChain, dmdict["model"], model_params))
dmdict: DecayModeDict = self._decay_mode_details(dm, display_photos_keyword)
model_params_list: list[str] = [str(i) for i in dmdict["model_params"]]
model_params: str = (
"" if model_params_list == [] else " ".join(model_params_list)
)
decay_chain: str = " ".join(list(dmdict["fs"])) # type: ignore[arg-type]
if len(decay_chain) > max_length:
max_length = len(decay_chain)
ls.append((dmdict["bf"], decay_chain, dmdict["model"], model_params))

# Sort decays by decreasing BF
ls = sorted(ls, key=lambda x: -x[0])

norm = 1.0
norm: float = 1.0
if normalize:
norm = sum(bf for bf, _, _, _ in ls)
elif scale is not None:
# Get the largest branching fraction
i = -1 if ascending else 0
norm = ls[i][0] / scale

maxLstr = str(maxLength + 2)
for bf, fs, model, modelPars in ls:
max_length_string = str(max_length + 2)
for bf, fs, model, model_params in ls:
if print_model:
line = " {:<10.5f} {:<{maxL}} {} {}".format(
bf / norm, fs, model, modelPars, maxL=maxLstr
line = " {:<10.5f} {:<{max_length}} {} {}".format(
bf / norm, fs, model, model_params, max_length=max_length_string
)
else:
line = f" {bf / norm:<10.7f} {fs}"
Expand Down

0 comments on commit aa66055

Please sign in to comment.