From a092f899b16c886bba2cb16bea07d5753bcf69df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:13:42 +0000 Subject: [PATCH 1/3] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.8.6) - [github.com/asottile/setup-cfg-fmt: v2.5.0 → v2.7.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.5.0...v2.7.0) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.14.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.14.1) - [github.com/kynan/nbstripout: 0.7.1 → 0.8.1](https://github.com/kynan/nbstripout/compare/0.7.1...0.8.1) - [github.com/mgedmin/check-manifest: 0.49 → 0.50](https://github.com/mgedmin/check-manifest/compare/0.49...0.50) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b860c2..9217a46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,38 +25,38 @@ repos: - id: trailing-whitespace - repo: https://github.com/psf/black - rev: "24.8.0" + rev: "24.10.0" hooks: - id: black-jupyter args: ["--line-length", "99"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.9" + rev: "v0.8.6" hooks: - id: ruff args: ["--fix", "--show-fixes"] - repo: https://github.com/asottile/setup-cfg-fmt - rev: "v2.5.0" + rev: "v2.7.0" hooks: - id: setup-cfg-fmt - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.11.2" + rev: "v1.14.1" hooks: - id: mypy files: src stages: [manual] - repo: https://github.com/kynan/nbstripout - rev: "0.7.1" + rev: "0.8.1" hooks: - id: nbstripout args: ["--drop-empty-cells", "--extra-keys", "metadata.kernelspec metadata.language_info"] - repo: https://github.com/mgedmin/check-manifest - rev: "0.49" + rev: "0.50" hooks: - id: check-manifest stages: [manual] From 30fa29f9e900d56af5994d451522ea3980a03d18 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:14:25 +0000 Subject: [PATCH 2/3] style: pre-commit fixes --- scripts/check_blinding.py | 2 +- scripts/util/__init__.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/check_blinding.py b/scripts/check_blinding.py index 4d8a6fa..42d7a59 100644 --- a/scripts/check_blinding.py +++ b/scripts/check_blinding.py @@ -92,7 +92,7 @@ # check for peaks within +- 5keV of 2614 and 583 to ensure blinding still # valid and if so create file else raise error. if detector is in ac mode it # will always pass this check -if np.any(np.abs(maxs - 2614) < 5) and np.any(np.abs(maxs - 583) < 5) or det_status is False: +if (np.any(np.abs(maxs - 2614) < 5) and np.any(np.abs(maxs - 583) < 5)) or det_status is False: pathlib.Path(os.path.dirname(args.output)).mkdir(parents=True, exist_ok=True) Props.write_to(args.output, {}) else: diff --git a/scripts/util/__init__.py b/scripts/util/__init__.py index 90b7204..3791977 100644 --- a/scripts/util/__init__.py +++ b/scripts/util/__init__.py @@ -12,18 +12,18 @@ ) __all__ = [ - "Props", - "PropsStream", "CalibCatalog", - "pars_key_resolve", - "dataset_file", + "ChannelProcKey", "FileKey", "ProcessingFileKey", - "ChannelProcKey", + "Props", + "PropsStream", + "dataset_file", "pars_catalog", - "unix_time", + "pars_key_resolve", "runcmd", - "subst_vars_impl", "subst_vars", + "subst_vars_impl", "subst_vars_in_snakemake_config", + "unix_time", ] From 9f888203098271bad747c459210417aafb2a0966 Mon Sep 17 00:00:00 2001 From: George Marshall Date: Thu, 9 Jan 2025 16:09:50 +0000 Subject: [PATCH 3/3] pc fixes --- scripts/build_tcm.py | 4 ++-- scripts/par_psp.py | 14 +++++++------- scripts/util/CalibCatalog.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/build_tcm.py b/scripts/build_tcm.py index c39faea..5a72300 100644 --- a/scripts/build_tcm.py +++ b/scripts/build_tcm.py @@ -41,9 +41,9 @@ fcid_channels[fcid].append(f"/{ch}/raw") # make a hardware_tcm_[fcid] for each fcid -for fcid in fcid_channels: +for fcid, fcid_dict in fcid_channels.items(): build_tcm( - [(args.input, fcid_channels[fcid])], + [(args.input, fcid_dict)], out_file=temp_output, out_name=f"hardware_tcm_{fcid}", wo_mode="o", diff --git a/scripts/par_psp.py b/scripts/par_psp.py index 52c2ed6..7427e97 100644 --- a/scripts/par_psp.py +++ b/scripts/par_psp.py @@ -51,16 +51,16 @@ for field in ave_fields: keys = field.split(".") vals = [] - for tstamp in in_dicts: - val = in_dicts[tstamp] + for _tstamp, tstamp_dict in in_dicts.items(): + val = tstamp_dict.copy() for key in keys: val = val[key] vals.append(val) - if "dsp" in in_dicts[tstamp]: - tmp_dict = in_dicts[tstamp]["dsp"] + if "dsp" in tstamp_dict: + tmp_dict = tstamp_dict["dsp"] else: tmp_dict = {} - in_dicts[tstamp]["dsp"] = tmp_dict + tstamp_dict["dsp"] = tmp_dict for i, key in enumerate(keys): if i == len(keys) - 1: tmp_dict[key] = val @@ -86,8 +86,8 @@ mean_val = np.nan if len(vals[~np.isnan(vals)]) == 0 else np.nanmedian(vals) mean = f"{round(mean_val, rounding)}*{unit}" if unit is not None else mean_val - for tstamp in in_dicts: - val = in_dicts[tstamp] + for _tstamp, tstamp_dict in in_dicts.items(): + val = tstamp_dict for i, key in enumerate(keys): if i == len(keys) - 1: val[key] = mean diff --git a/scripts/util/CalibCatalog.py b/scripts/util/CalibCatalog.py index b222c5d..6cd8e29 100644 --- a/scripts/util/CalibCatalog.py +++ b/scripts/util/CalibCatalog.py @@ -99,8 +99,8 @@ def read_from(file_name): entries[system] = [] entries[system].append(CalibCatalog.Entry(unix_time(timestamp), file_key)) - for system in entries: - entries[system] = sorted(entries[system], key=lambda entry: entry.valid_from) + for system, system_dict in entries.items(): + entries[system] = sorted(system_dict, key=lambda entry: entry.valid_from) return CalibCatalog(entries) def calib_for(self, timestamp, category="all", allow_none=False):