From efd477ae9b410d2d653c27b061abdd908ebd677f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2026 19:01:11 +0000 Subject: [PATCH 1/7] autoupdate pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.12 → v0.15.20](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.12...v0.15.20) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a2c78a..cd19125 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: - id: blacken-docs args: [-l 100] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.12 + rev: v0.15.20 hooks: - id: ruff args: [--fix, --show-fixes] From 7c144e0053faa41926aaae15fe36bcb3982ef113 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Fri, 11 Jul 2025 15:54:01 -0500 Subject: [PATCH 2/7] Add hash to functions with __eq__() as advised by ruff --- src/simweights/_generation_surface.py | 5 ++++- src/simweights/_powerlaw.py | 3 +++ src/simweights/_spatial.py | 6 ++++++ src/simweights/_utils.py | 6 ++++++ tests/test_weighter.py | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/simweights/_generation_surface.py b/src/simweights/_generation_surface.py index eb3f2de..a4b0c2c 100644 --- a/src/simweights/_generation_surface.py +++ b/src/simweights/_generation_surface.py @@ -159,7 +159,10 @@ def get_cos_zenith_range(self: "CompositeSurface", pdgid: "PDGCode | None" = Non assert np.isfinite(czmax) return czmin, czmax - def __eq__(self, other: object) -> bool: + def __hash__(self) -> int: + return hash(self.spectra) + + def __eq__(self: GenerationSurface, other: object) -> bool: # must handle the same set of particle types if isinstance(other, GenerationSurface): return self == CompositeSurface(other) diff --git a/src/simweights/_powerlaw.py b/src/simweights/_powerlaw.py index 285aa76..304bf5c 100644 --- a/src/simweights/_powerlaw.py +++ b/src/simweights/_powerlaw.py @@ -118,6 +118,9 @@ def rvs(self: PowerLaw, size: Any = None, random_state: SeedType = None) -> NDAr def __repr__(self: PowerLaw) -> str: return f"{self.__class__.__name__}({self.g} ,{self.a}, {self.b})" + def __hash__(self) -> int: + return hash((self.g, self.a, self.b)) + def __eq__(self: PowerLaw, other: object) -> bool: if not isinstance(other, PowerLaw): mesg = f"{self} cannot be compared to {other}" diff --git a/src/simweights/_spatial.py b/src/simweights/_spatial.py index b56f312..9fdaa40 100644 --- a/src/simweights/_spatial.py +++ b/src/simweights/_spatial.py @@ -64,6 +64,9 @@ def __repr__(self: CylinderBase) -> str: f"{self.cos_zen_min:1.4g}, {self.cos_zen_max:1.4g})" ) + def __hash__(self) -> int: + return hash((self.length, self.radius, self.cos_zen_min, self.cos_zen_max)) + def __eq__(self: CylinderBase, other: object) -> bool: return ( isinstance(other, type(self)) @@ -164,6 +167,9 @@ def pdf(self: CircleInjector, cos_zen: ArrayLike) -> NDArray[np.float64]: def __repr__(self: CircleInjector) -> str: return f"CircleInjector({self.radius:1.4g}, {self.cos_zen_min:1.4g}, {self.cos_zen_max:1.4g})" + def __hash__(self) -> int: + return hash((self.radius, self.cos_zen_min, self.cos_zen_max)) + def __eq__(self: CircleInjector, other: object) -> bool: return ( isinstance(other, CircleInjector) diff --git a/src/simweights/_utils.py b/src/simweights/_utils.py index add4a17..45a5695 100644 --- a/src/simweights/_utils.py +++ b/src/simweights/_utils.py @@ -31,6 +31,9 @@ def pdf(self: Column, value: ArrayLike) -> NDArray[np.floating]: r"""Probability density function.""" return 1.0 / np.asarray(value, dtype=np.float64) + def __hash__(self) -> int: + return hash(self.columns) + def __eq__(self: Column, other: object) -> bool: return isinstance(other, Column) and self.columns == other.columns @@ -49,6 +52,9 @@ def pdf(self: Const) -> NDArray[np.float64]: r"""Probability density function.""" return np.asarray(self.v, dtype=np.float64) + def __hash__(self) -> int: + return hash(self.v) + def __eq__(self: Const, other: object) -> bool: return isinstance(other, Const) and self.v == other.v diff --git a/tests/test_weighter.py b/tests/test_weighter.py index 2d13375..f3f0898 100755 --- a/tests/test_weighter.py +++ b/tests/test_weighter.py @@ -4,6 +4,7 @@ # # SPDX-License-Identifier: BSD-2-Clause +import contextlib import unittest from copy import deepcopy @@ -11,6 +12,9 @@ from simweights import TIG1996, IceTopSurface, NaturalRateCylinder, NuGenSurface, PowerLaw, Weighter +with contextlib.suppress(ImportError): + import nuflux + def fluxfun1(energy): return energy**2 From 36bc66d45adaf67bcf7eecf9670176f51bbf4caa Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Tue, 22 Jul 2025 13:37:38 -0500 Subject: [PATCH 3/7] remove hash functions --- pyproject.toml | 1 + src/simweights/_generation_surface.py | 3 --- src/simweights/_powerlaw.py | 3 --- src/simweights/_spatial.py | 6 ------ src/simweights/_utils.py | 6 ------ 5 files changed, 1 insertion(+), 18 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f4e00ae..839fc15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ ignore = [ "S101", # assert-used "COM812", # conflicts with ruff formatter "ISC001", # conflicts with ruff formatter + "PLR0913", # Too many arguments in function definition "PLR0911", # Too many return statement "PLW1641" # object does not implement `__hash__` method ] diff --git a/src/simweights/_generation_surface.py b/src/simweights/_generation_surface.py index a4b0c2c..a7df87d 100644 --- a/src/simweights/_generation_surface.py +++ b/src/simweights/_generation_surface.py @@ -159,9 +159,6 @@ def get_cos_zenith_range(self: "CompositeSurface", pdgid: "PDGCode | None" = Non assert np.isfinite(czmax) return czmin, czmax - def __hash__(self) -> int: - return hash(self.spectra) - def __eq__(self: GenerationSurface, other: object) -> bool: # must handle the same set of particle types if isinstance(other, GenerationSurface): diff --git a/src/simweights/_powerlaw.py b/src/simweights/_powerlaw.py index 304bf5c..285aa76 100644 --- a/src/simweights/_powerlaw.py +++ b/src/simweights/_powerlaw.py @@ -118,9 +118,6 @@ def rvs(self: PowerLaw, size: Any = None, random_state: SeedType = None) -> NDAr def __repr__(self: PowerLaw) -> str: return f"{self.__class__.__name__}({self.g} ,{self.a}, {self.b})" - def __hash__(self) -> int: - return hash((self.g, self.a, self.b)) - def __eq__(self: PowerLaw, other: object) -> bool: if not isinstance(other, PowerLaw): mesg = f"{self} cannot be compared to {other}" diff --git a/src/simweights/_spatial.py b/src/simweights/_spatial.py index 9fdaa40..b56f312 100644 --- a/src/simweights/_spatial.py +++ b/src/simweights/_spatial.py @@ -64,9 +64,6 @@ def __repr__(self: CylinderBase) -> str: f"{self.cos_zen_min:1.4g}, {self.cos_zen_max:1.4g})" ) - def __hash__(self) -> int: - return hash((self.length, self.radius, self.cos_zen_min, self.cos_zen_max)) - def __eq__(self: CylinderBase, other: object) -> bool: return ( isinstance(other, type(self)) @@ -167,9 +164,6 @@ def pdf(self: CircleInjector, cos_zen: ArrayLike) -> NDArray[np.float64]: def __repr__(self: CircleInjector) -> str: return f"CircleInjector({self.radius:1.4g}, {self.cos_zen_min:1.4g}, {self.cos_zen_max:1.4g})" - def __hash__(self) -> int: - return hash((self.radius, self.cos_zen_min, self.cos_zen_max)) - def __eq__(self: CircleInjector, other: object) -> bool: return ( isinstance(other, CircleInjector) diff --git a/src/simweights/_utils.py b/src/simweights/_utils.py index 45a5695..add4a17 100644 --- a/src/simweights/_utils.py +++ b/src/simweights/_utils.py @@ -31,9 +31,6 @@ def pdf(self: Column, value: ArrayLike) -> NDArray[np.floating]: r"""Probability density function.""" return 1.0 / np.asarray(value, dtype=np.float64) - def __hash__(self) -> int: - return hash(self.columns) - def __eq__(self: Column, other: object) -> bool: return isinstance(other, Column) and self.columns == other.columns @@ -52,9 +49,6 @@ def pdf(self: Const) -> NDArray[np.float64]: r"""Probability density function.""" return np.asarray(self.v, dtype=np.float64) - def __hash__(self) -> int: - return hash(self.v) - def __eq__(self: Const, other: object) -> bool: return isinstance(other, Const) and self.v == other.v From 52b8d1651dce6e5c70f0eee19005875fb4aebfd7 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Mon, 13 Jul 2026 14:49:42 -0500 Subject: [PATCH 4/7] ruff v0.15.20 -> v0.15.21 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd19125..efda701 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: - id: blacken-docs args: [-l 100] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.15.21 hooks: - id: ruff args: [--fix, --show-fixes] From 21ebb094e7ae7d66b7609809a35bf4be4e63c40f Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Mon, 13 Jul 2026 14:50:47 -0500 Subject: [PATCH 5/7] remove python 3.15 --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 04682da..4cc4273 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,8 +23,6 @@ jobs: include: - python-version: "3.14" os: macos-26 - - python-version: "3.15" - os: macos-26 steps: - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} From e148b5789419b43933123debdc9fd60efe1f92d5 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Mon, 13 Jul 2026 14:52:44 -0500 Subject: [PATCH 6/7] remove noqa --- tests/test_weighter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_weighter.py b/tests/test_weighter.py index f3f0898..935ef14 100755 --- a/tests/test_weighter.py +++ b/tests/test_weighter.py @@ -315,7 +315,7 @@ def test_nuflux(self): weighter1.add_weight_column("energy", data1["I3Weight"]["energy"]) weighter1.add_weight_column("cos_zen", np.cos(data1["I3Weight"]["zenith"])) - honda = nuflux.makeFlux("honda2006") # noqa : F821 + honda = nuflux.makeFlux("honda2006") w = weighter1.get_weights(honda) fluxval = honda.getFlux(14, data1["I3Weight"]["energy"], np.cos(data1["I3Weight"]["zenith"])) oneweight = weighter1.get_weights(1) From 00123b8a451fb473ed1e67c3120ee0fa00bbe6d1 Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Mon, 13 Jul 2026 14:58:46 -0500 Subject: [PATCH 7/7] remove icetray tests --- .github/workflows/tests.yml | 60 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4cc4273..63975d4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,36 +58,36 @@ jobs: with: fail_ci_if_error: false verbose: true - TestsIceTray: - env: - UV_SYSTEM_PYTHON: 1 - runs-on: ubuntu-latest - container: icecube/icetray:icetray-devel-current-ubuntu22.04-X64 - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v6 - - name: Install uv - uses: astral-sh/setup-uv@v7 - with: - enable-cache: true - - name: Install SimWeights - run: uv pip install -e .[test] - - name: Download Test Data - run: | - curl -u icecube:${{ secrets.ICECUBE_PASSWORD }} https://convey.icecube.wisc.edu/data/ana/Software/simweights/test-data/simweights_testdata.tar.gz -O - tar xzvf simweights_testdata.tar.gz - - name: Run Unit Tests - env: - SIMWEIGHTS_TESTDATA: . - run: /opt/icetray/bin/icetray-shell python -m pytest --junit-xml=test-results-icetray.junit.xml - - name: Upload Test Results - uses: actions/upload-artifact@v7 - if: always() - with: - if-no-files-found: error - name: test-results-icetray.junit.xml - path: test-results-icetray.junit.xml + # TestsIceTray: + # env: + # UV_SYSTEM_PYTHON: 1 + # runs-on: ubuntu-latest + # container: icecube/icetray:icetray-devel-current-ubuntu22.04-X64 + # strategy: + # fail-fast: false + # steps: + # - uses: actions/checkout@v6 + # - name: Install uv + # uses: astral-sh/setup-uv@v7 + # with: + # enable-cache: true + # - name: Install SimWeights + # run: uv pip install -e .[test] + # - name: Download Test Data + # run: | + # curl -u icecube:${{ secrets.ICECUBE_PASSWORD }} https://convey.icecube.wisc.edu/data/ana/Software/simweights/test-data/simweights_testdata.tar.gz -O + # tar xzvf simweights_testdata.tar.gz + # - name: Run Unit Tests + # env: + # SIMWEIGHTS_TESTDATA: . + # run: /opt/icetray/bin/icetray-shell python -m pytest --junit-xml=test-results-icetray.junit.xml + # - name: Upload Test Results + # uses: actions/upload-artifact@v7 + # if: always() + # with: + # if-no-files-found: error + # name: test-results-icetray.junit.xml + # path: test-results-icetray.junit.xml publish-test-results: name: "Publish Tests Results" needs: Tests