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 Apr 1, 2024
1 parent 1b5aa88 commit cb2d787
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 36 deletions.
1 change: 1 addition & 0 deletions docs/source/extensions/numbadoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Adapted from https://github.com/numba/numba/issues/5755#issuecomment-646587651
"""

from copy import copy
from typing import Iterator, List

Expand Down
1 change: 1 addition & 0 deletions src/pygama/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
pygama's command line interface utilities.
"""

import argparse
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions src/pygama/evt/modules/legend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module provides LEGEND internal functions
"""

from importlib import import_module

from lgdo.lh5 import utils
Expand Down
1 change: 0 additions & 1 deletion src/pygama/evt/modules/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
additional parameters are free to the user and need to be defined in the JSON
"""


import awkward as ak
import numpy as np
from lgdo import Array, VectorOfVectors
Expand Down
1 change: 1 addition & 0 deletions src/pygama/flow/file_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for LH5 file inventory."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions src/pygama/hit/build_hit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module implements routines to evaluate expressions to columnar data.
"""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions src/pygama/logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module implements some helpers for setting up logging."""

import logging

import colorlog
Expand Down
51 changes: 29 additions & 22 deletions src/pygama/pargen/AoE_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


class PDF:

"""
Base class for A/E pdfs.
"""
Expand Down Expand Up @@ -1518,9 +1517,9 @@ def drift_time_correction(
np.nanpercentile(dep_events[self.dt_param], 99),
]

self.dt_res_dict[
"final_selection"
] = f"{aoe_param}>{aoe_range[0]}&{aoe_param}<{aoe_range[1]}&{self.dt_param}>{dt_range[0]}&{self.dt_param}<{dt_range[1]}&{self.dt_param}=={self.dt_param}"
self.dt_res_dict["final_selection"] = (
f"{aoe_param}>{aoe_range[0]}&{aoe_param}<{aoe_range[1]}&{self.dt_param}>{dt_range[0]}&{self.dt_param}<{dt_range[1]}&{self.dt_param}=={self.dt_param}"
)

final_df = dep_events.query(self.dt_res_dict["final_selection"])

Expand Down Expand Up @@ -1550,12 +1549,12 @@ def drift_time_correction(
"errs": m.errors,
"object": m,
}
aoe_grp1 = self.dt_res_dict[
"aoe_grp1"
] = f'{self.dt_param}>{m.values["mu1"] - 2 * m.values["sigma1"]} & {self.dt_param}<{m.values["mu1"] + 2 * m.values["sigma1"]}'
aoe_grp2 = self.dt_res_dict[
"aoe_grp2"
] = f'{self.dt_param}>{m.values["mu2"] - 2 * m.values["sigma2"]} & {self.dt_param}<{m.values["mu2"] + 2 * m.values["sigma2"]}'
aoe_grp1 = self.dt_res_dict["aoe_grp1"] = (
f'{self.dt_param}>{m.values["mu1"] - 2 * m.values["sigma1"]} & {self.dt_param}<{m.values["mu1"] + 2 * m.values["sigma1"]}'
)
aoe_grp2 = self.dt_res_dict["aoe_grp2"] = (
f'{self.dt_param}>{m.values["mu2"] - 2 * m.values["sigma2"]} & {self.dt_param}<{m.values["mu2"] + 2 * m.values["sigma2"]}'
)

aoe_pars, aoe_errs, _ = unbinned_aoe_fit(
final_df.query(aoe_grp1)[aoe_param], pdf=self.pdf, display=display
Expand Down Expand Up @@ -2021,9 +2020,11 @@ def calibrate(self, df, initial_aoe_param):
self.low_cut_val,
peak,
fwhm,
dt_mask=peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None,
dt_mask=(
peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None
),
)
self.low_side_sf = pd.concat(
[
Expand All @@ -2043,9 +2044,11 @@ def calibrate(self, df, initial_aoe_param):
self.low_cut_val,
peak,
fwhm,
dt_mask=peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None,
dt_mask=(
peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None
),
)
self.low_side_sf = pd.concat(
[
Expand Down Expand Up @@ -2083,9 +2086,11 @@ def calibrate(self, df, initial_aoe_param):
peak_df[aoe_param].to_numpy(),
self.low_cut_val,
self.high_cut_val,
dt_mask=peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None,
dt_mask=(
peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None
),
)
sf = sf_dict["sf"]
sf_err = sf_dict["sf_err"]
Expand All @@ -2107,9 +2112,11 @@ def calibrate(self, df, initial_aoe_param):
peak,
fwhm,
high_cut=self.high_cut_val,
dt_mask=peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None,
dt_mask=(
peak_df[self.dt_cut_param].to_numpy()
if self.dt_cut_param is not None
else None
),
)
self.two_side_sf = pd.concat(
[
Expand Down
1 change: 1 addition & 0 deletions src/pygama/pargen/data_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- find_pulser_properties (find pulser by looking for which peak has a constant time between events)
- tag_pulsers
"""

import matplotlib.gridspec as gs
import matplotlib.pyplot as plt
import numpy as np
Expand Down
20 changes: 8 additions & 12 deletions src/pygama/pargen/ecal_th.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,13 +1183,11 @@ def bin_pulser_stability(ecal_class, data, pulser_field="is_pulser", time_slice=
"spread": np.full_like(times_average, np.nan),
}

nanmedian = (
lambda x: np.nanpercentile(x, 50) if len(x[~np.isnan(x)]) >= 10 else np.nan
nanmedian = lambda x: (
np.nanpercentile(x, 50) if len(x[~np.isnan(x)]) >= 10 else np.nan
)
error = (
lambda x: np.nanvar(x) / np.sqrt(len(x))
if len(x[~np.isnan(x)]) >= 10
else np.nan
error = lambda x: (
np.nanvar(x) / np.sqrt(len(x)) if len(x[~np.isnan(x)]) >= 10 else np.nan
)

par_average, _, _ = binned_statistic(
Expand Down Expand Up @@ -1225,13 +1223,11 @@ def bin_stability(ecal_class, data, time_slice=180, energy_range=[2585, 2660]):
"spread": np.full_like(times_average, np.nan),
}

nanmedian = (
lambda x: np.nanpercentile(x, 50) if len(x[~np.isnan(x)]) >= 10 else np.nan
nanmedian = lambda x: (
np.nanpercentile(x, 50) if len(x[~np.isnan(x)]) >= 10 else np.nan
)
error = (
lambda x: np.nanvar(x) / np.sqrt(len(x))
if len(x[~np.isnan(x)]) >= 10
else np.nan
error = lambda x: (
np.nanvar(x) / np.sqrt(len(x)) if len(x[~np.isnan(x)]) >= 10 else np.nan
)

par_average, _, _ = binned_statistic(
Expand Down
1 change: 1 addition & 0 deletions src/pygama/pargen/energy_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- hpge_fit_E_peaks (fits the energy peals)
- hpge_E_calibration (main routine -- finds and fits peaks specified)
"""

import logging
import sys

Expand Down
1 change: 0 additions & 1 deletion src/pygama/pargen/lq_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def fit_time_means(tstamps, means, reses):


class cal_lq:

"""A class for calibrating the LQ parameter and determining the LQ cut value"""

def __init__(
Expand Down

0 comments on commit cb2d787

Please sign in to comment.