From a6d5aacbe48ffbe6fd65b52eb3ffa0e2059de92e Mon Sep 17 00:00:00 2001 From: ggmarshall <72088559+ggmarshall@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:53:59 +0000 Subject: [PATCH 1/8] Bug fix: `evt.modules.spm.cast_trigger` where Awkward arrays not replacing `nan`s (#559) * fixed bug in cast_triger where awk arrays not replacing nans --- src/pygama/evt/modules/spm.py | 8 +++++--- src/pygama/flow/utils.py | 7 +------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pygama/evt/modules/spm.py b/src/pygama/evt/modules/spm.py index 2dc5a4290..6e7140d17 100644 --- a/src/pygama/evt/modules/spm.py +++ b/src/pygama/evt/modules/spm.py @@ -37,11 +37,13 @@ def cast_trigger( ak.min(ak.fill_none(trgr.view_as("ak"), tdefault), axis=-1), tdefault ) - elif isinstance(trgr, ak.Array): + elif isinstance(trgr, (ak.Array, ak.highlevel.Array)): if trgr.ndim == 1: - return ak.fill_none(trgr, tdefault) + return ak.fill_none(ak.nan_to_none(trgr), tdefault) elif trgr.ndim == 2: - return ak.fill_none(ak.min(ak.fill_none(trgr, tdefault), axis=-1), tdefault) + return ak.fill_none( + ak.min(ak.fill_none(ak.nan_to_none(trgr), tdefault), axis=-1), tdefault + ) else: raise ValueError(f"Too many dimensions: {trgr.ndim}") elif isinstance(trgr, (float, int)) and isinstance(length, int): diff --git a/src/pygama/flow/utils.py b/src/pygama/flow/utils.py index c51cd6898..eef8b3983 100644 --- a/src/pygama/flow/utils.py +++ b/src/pygama/flow/utils.py @@ -122,12 +122,7 @@ def fill_col_dict( (table_length, len(tier_table[col].nda[0])), dtype=tier_table[col].dtype, ) - try: - col_dict[col][tcm_idx] = tier_table[col].nda - except BaseException: - raise ValueError( - f"self.aoesa_to_vov is False but {col} is a jagged array" - ) + col_dict[col][tcm_idx] = tier_table[col].nda elif isinstance(tier_table[col], VectorOfVectors): # Allocate memory for column for all channels if col not in col_dict.keys(): From e5f02b0bd328f542873ea6f55123c91e0b92c0d5 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Mon, 19 Feb 2024 15:28:45 +0100 Subject: [PATCH 2/8] Bump lgdo version and ignore Pandas/Pyarrow deprecation warning --- pyproject.toml | 2 +- setup.cfg | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4d08123b8..1dcd76af8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ write_to = "src/pygama/_version.py" minversion = "6.0" addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] xfail_strict = true -filterwarnings = ["error"] +filterwarnings = ["error", 'ignore:\nPyarrow:DeprecationWarning'] log_cli_level = "info" testpaths = "tests" diff --git a/setup.cfg b/setup.cfg index 74c036924..9d3080bbc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,13 +36,12 @@ install_requires = h5py>=3.2 iminuit legend-daq2lh5>=1.2.0a1 - legend-pydataobj>=1.5.0a2 + legend-pydataobj>=1.5.0a5 matplotlib numba!=0.53.*,!=0.54.*,!=0.57 numpy>=1.21 pandas>=1.4.4 pint - pyarrow scikit-learn scipy>=1.0.1 tables From 69d89b0837f9fa32ee49824b18585f59b97dab03 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Tue, 20 Feb 2024 22:04:01 +0100 Subject: [PATCH 3/8] Add CITATION.cff (#556) * [docs] add draft CITATION.cff --------- Co-authored-by: Jason Detwiler --- CITATION.cff | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 000000000..9782d1ac8 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,58 @@ +cff-version: 1.2.0 +title: pygama +doi: FILLME +date-released: 2024-02-01 +url: https://github.com/github-linguist/linguist +message: "If you use this software, please cite it as below." +authors: + - family-names: Agostini + given-names: Matteo + orcid: https://orcid.org/0000-0003-1151-5301 + - family-names: Detwiler + given-names: Jason + orcid: https://orcid.org/0000-0002-9050-4610 + - family-names: Pertoldi + given-names: Luigi + orcid: https://orcid.org/0000-0002-0467-2571 + - family-names: Guinn + given-names: Ian + orcid: https://orcid.org/0000-0002-2424-3272 + - family-names: Marshall + given-names: George + orcid: https://orcid.org/0000-0002-5470-5132 + - family-names: D'Andrea + given-names: Valerio + orcid: https://orcid.org/0000-0003-2037-4133 + - family-names: Krause + given-names: Patrick + orcid: https://orcid.org/0000-0002-9603-7865 + - family-names: Song + given-names: Grace + email: grsong@uw.edu + - family-names: Engelhardt + given-names: Erin + email: erin717@live.unc.edu + - family-names: Borden + given-names: Sam + orcid: https://orcid.org/0009-0003-2539-4333 + - family-names: Deckert + given-names: Rosanna + orcid: https://orcid.org/0009-0006-0431-341X + - family-names: Sweigart + given-names: David + email: dsweigar@uw.edu + - family-names: Zschocke + given-names: Andreas + email: Andreas.Zschocke@uni-tuebingen.de + - family-names: Wiseman + given-names: Clint + orcid: https://orcid.org/0000-0002-4232-1326 + - family-names: Mathew + given-names: Tim + email: tmathew@uoregon.edu + - family-names: Kermaïdic + given-names: Yoann + orcid: https://orcid.org/0000-0001-8007-8016 + - family-names: Shanks + given-names: Ben + email: benjamin.shanks@gmail.com From a0085207d2a6965841810292b56ca9137eba4dc2 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 11:20:38 +0100 Subject: [PATCH 4/8] Update citation-related docs --- CITATION.cff | 4 ++-- README.md | 14 +++++++++++--- docs/source/index.rst | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 9782d1ac8..90524f881 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,7 +1,7 @@ cff-version: 1.2.0 title: pygama -doi: FILLME -date-released: 2024-02-01 +doi: https://doi.org/10.5281/zenodo.10614246 +date-released: 2024-02-03 url: https://github.com/github-linguist/linguist message: "If you use this software, please cite it as below." authors: diff --git a/README.md b/README.md index 54fecb59d..8abf4f7e5 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ [![GitHub pull requests](https://img.shields.io/github/issues-pr/legend-exp/pygama?logo=github)](https://github.com/legend-exp/pygama/pulls) [![License](https://img.shields.io/github/license/legend-exp/pygama)](https://github.com/legend-exp/pygama/blob/main/LICENSE) [![Read the Docs](https://img.shields.io/readthedocs/pygama?logo=readthedocs)](https://pygama.readthedocs.io) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10614246.svg)](https://zenodo.org/doi/10.5281/zenodo.10614246) *pygama* is a Python package for: @@ -28,7 +29,14 @@ Check out the [online documentation](https://pygama.readthedocs.io). +If you are using this software, consider +[citing](https://zenodo.org/doi/10.5281/zenodo.10614246)! + ## Related repositories -- [legend-exp/legend-pydataobj](https://github.com/legend-exp/legend-pydataobj) → LEGEND Python Data Objects -- [legend-exp/legend-daq2lh5](https://github.com/legend-exp/legend-daq2lh5) → Convert digitizer data to LEGEND HDF5 -- [legend-exp/dspeed](https://github.com/legend-exp/dspeed) → Fast Digital Signal Processing for particle detector signals in Python + +- [legend-exp/legend-pydataobj](https://github.com/legend-exp/legend-pydataobj) + → LEGEND Python Data Objects +- [legend-exp/legend-daq2lh5](https://github.com/legend-exp/legend-daq2lh5) + → Convert digitizer data to LEGEND HDF5 +- [legend-exp/dspeed](https://github.com/legend-exp/dspeed) + → Fast Digital Signal Processing for particle detector signals in Python diff --git a/docs/source/index.rst b/docs/source/index.rst index e3972f81f..cf78de997 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -65,5 +65,6 @@ Next steps Source Code License + Citation Changelog developer From db324ffb8e5181d8f67dc39d2231e596ff2b7990 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 11:22:08 +0100 Subject: [PATCH 5/8] [ci] update workflow files --- .github/workflows/distribution.yml | 49 ++++++++++++++++-------------- .github/workflows/main.yml | 7 +++-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/.github/workflows/distribution.yml b/.github/workflows/distribution.yml index 63e9c51e7..61aa724a4 100644 --- a/.github/workflows/distribution.yml +++ b/.github/workflows/distribution.yml @@ -2,42 +2,47 @@ name: distribute on: workflow_dispatch: + pull_request: push: - tags: "v*" + branches: + - main release: types: - published -jobs: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + FORCE_COLOR: 3 +jobs: dist: + name: Distribution build runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build SDist and wheel - run: pipx run build - - - uses: actions/upload-artifact@v4 - with: - path: dist/* + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Check metadata - run: pipx run twine check dist/* + - uses: hynek/build-and-inspect-python-package@v2 publish: needs: [dist] + name: Publish to PyPI + environment: pypi + permissions: + id-token: write runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v4 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@v1.8.11 - with: - password: ${{ secrets.pypi_password }} + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + if: github.event_name == 'release' && github.event.action == 'published' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24b9bfbd8..76eb5c78b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,18 +1,19 @@ name: pygama on: + workflow_dispatch: + pull_request: push: branches: - main - - 'releases/**' - pull_request: - release: + - "releases/**" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: + FORCE_COLOR: 3 TQDM_MININTERVAL: 100 jobs: From 3dccd974764e976e0c1decbdfa2db853e135c431 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 11:26:37 +0100 Subject: [PATCH 6/8] Update subpackage descriptions to silence wheel checking failure in CI --- src/pygama/math/__init__.py | 2 +- src/pygama/pargen/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pygama/math/__init__.py b/src/pygama/math/__init__.py index cca7a6038..93b88f477 100644 --- a/src/pygama/math/__init__.py +++ b/src/pygama/math/__init__.py @@ -1,3 +1,3 @@ """ -Subpackage description +Statistical and mathematical utilities. """ diff --git a/src/pygama/pargen/__init__.py b/src/pygama/pargen/__init__.py index cca7a6038..3dcede5b7 100644 --- a/src/pygama/pargen/__init__.py +++ b/src/pygama/pargen/__init__.py @@ -1,3 +1,4 @@ """ -Subpackage description +Utilities to generate and optimize parameters of interest from data (e.g. +calibration routines) """ From d7d3c8183faf9294440173dd010703e1f51cde82 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Wed, 28 Feb 2024 11:44:00 +0100 Subject: [PATCH 7/8] [setup] transition to pure pyproject.toml --- .pre-commit-config.yaml | 1 + pyproject.toml | 113 ++++++++++++++++++++++++++++++++++++++-- setup.cfg | 86 ------------------------------ setup.py | 4 -- 4 files changed, 111 insertions(+), 93 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0bc4718d..02ffb3e94 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,6 +70,7 @@ repos: flake8-print, pep8-naming ] + args: ["--extend-ignore", "E203,E501"] - repo: https://github.com/kynan/nbstripout rev: "0.6.1" diff --git a/pyproject.toml b/pyproject.toml index 1dcd76af8..8f759a09d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,121 @@ [build-system] requires = [ - "setuptools>=42.0.0", - "setuptools_scm[toml]>=3.4", + "setuptools>=61.2", + "setuptools_scm[toml]>=7", ] - build-backend = "setuptools.build_meta" +[project] +name = "pygama" +description = "Python package for data processing and analysis" +authors = [ + { name = "The LEGEND collaboration" }, +] +maintainers = [ + { name = "The LEGEND collaboration" }, +] +readme = "README.md" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: MacOS", + "Operating System :: POSIX", + "Operating System :: Unix", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering", +] +requires-python = ">=3.9" +dependencies = [ + "colorlog", + "dspeed>=1.3.0a4", + "h5py>=3.2", + "iminuit", + "legend-daq2lh5>=1.2.0a1", + "legend-pydataobj>=1.5.0a5", + "matplotlib", + "numba!=0.53.*,!=0.54.*,!=0.57", + "numpy>=1.21", + "pandas>=1.4.4", + "pint", + "scikit-learn", + "scipy>=1.0.1", + "tables", + "tqdm>=4.27", +] +dynamic = [ + "version", +] + +[project.urls] +Homepage = "https://github.com/legend-exp/pygama" +"Bug Tracker" = "https://github.com/legend-exp/pygama/issues" +Discussions = "https://github.com/legend-exp/pygama/discussions" +Changelog = "https://github.com/legend-exp/pygama/releases" + [tool.setuptools_scm] write_to = "src/pygama/_version.py" +[project.optional-dependencies] +all = [ + "pygama[docs,test]", +] +docs = [ + "furo", + "jupyter", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-copybutton", + "sphinx-inline-tabs", +] +test = [ + "pre-commit", + "pylegendtestdata", + "pytest>=6.0", + "pytest-cov", +] + +[project.scripts] +pygama = "pygama.cli:pygama_cli" + +[tool.setuptools] +include-package-data = true +zip-safe = false +license-files = [ + "LICENSE", +] + +[tool.setuptools.package-dir] +"" = "src" + +[tool.setuptools.packages.find] +where = [ + "src", +] +namespaces = false + +[tool.setuptools.package-data] +"*" = [ + "*.json", +] + +[tool.coverage] +run.source = ["pygama"] +report.exclude_also = [ + '\.\.\.', + 'if typing.TYPE_CHECKING:', +] + +[tool.flake8] +extend-ignore = "E203, E501" + +[tool.codespell] +ignore-words-list = "hist, gaus, nd, ans, crate, nin, puls, spms, fom" + [tool.pytest.ini_options] minversion = "6.0" addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9d3080bbc..000000000 --- a/setup.cfg +++ /dev/null @@ -1,86 +0,0 @@ -[metadata] -name = pygama -description = Python package for decoding and processing digitizer data -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/legend-exp/pygama -author = The LEGEND collaboration -maintainer = The LEGEND collaboration -license = GPL-3.0 -license_files = LICENSE -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Developers - Intended Audience :: Information Technology - Intended Audience :: Science/Research - License :: OSI Approved :: GNU General Public License v3 (GPLv3) - Operating System :: MacOS - Operating System :: POSIX - Operating System :: Unix - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Information Analysis - Topic :: Scientific/Engineering :: Mathematics - Topic :: Scientific/Engineering :: Physics - Topic :: Software Development -project_urls = - Documentation = https://pygama.readthedocs.io - -[options] -packages = find: -install_requires = - colorlog - dspeed>=1.3.0a4 - h5py>=3.2 - iminuit - legend-daq2lh5>=1.2.0a1 - legend-pydataobj>=1.5.0a5 - matplotlib - numba!=0.53.*,!=0.54.*,!=0.57 - numpy>=1.21 - pandas>=1.4.4 - pint - scikit-learn - scipy>=1.0.1 - tables - tqdm>=4.27 -python_requires = >=3.9 -include_package_data = True -package_dir = - = src -zip_safe = False - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - pygama = pygama.cli:pygama_cli - -[options.extras_require] -all = - pygama[docs,test] -docs = - furo - jupyter - myst-parser - nbsphinx - sphinx - sphinx-copybutton - sphinx-inline-tabs -test = - pre-commit - pylegendtestdata - pytest>=6.0 - pytest-cov - -[options.package_data] -* = *.json - -[flake8] -extend-ignore = E203, E501 - -[codespell] -ignore-words-list = hist, gaus, nd, ans, crate, nin, puls, spms, fom diff --git a/setup.py b/setup.py deleted file mode 100644 index f6844919c..000000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -import setuptools_scm # noqa: F401 -from setuptools import setup - -setup() From ae3752ab079a944217c2dc203ad7cbd5b5bea0c5 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Fri, 1 Mar 2024 11:43:53 +0100 Subject: [PATCH 8/8] [setup] bump LEGEND package versions --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f759a09d..0b196a424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,11 +31,11 @@ classifiers = [ requires-python = ">=3.9" dependencies = [ "colorlog", - "dspeed>=1.3.0a4", + "dspeed>=1.3", "h5py>=3.2", "iminuit", - "legend-daq2lh5>=1.2.0a1", - "legend-pydataobj>=1.5.0a5", + "legend-daq2lh5>=1.2", + "legend-pydataobj>=1.5", "matplotlib", "numba!=0.53.*,!=0.54.*,!=0.57", "numpy>=1.21",