From c6d362065bb0e46ab8d705a1c9eea54e1548278a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 23:49:53 +0000 Subject: [PATCH 1/2] Bump the actions group with 2 updates Bumps the actions group with 2 updates: [scientific-python/repo-review](https://github.com/scientific-python/repo-review) and [codecov/codecov-action](https://github.com/codecov/codecov-action). Updates `scientific-python/repo-review` from 0.10.6 to 0.11.0 - [Release notes](https://github.com/scientific-python/repo-review/releases) - [Changelog](https://github.com/scientific-python/repo-review/blob/main/docs/changelog.md) - [Commits](https://github.com/scientific-python/repo-review/compare/v0.10.6...v0.11.0) Updates `codecov/codecov-action` from 4.3.0 to 4.3.1 - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4.3.0...v4.3.1) --- updated-dependencies: - dependency-name: scientific-python/repo-review dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02dd98b..c341840 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: | echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" pipx run nox -s pylint - - uses: scientific-python/repo-review@v0.10.6 + - uses: scientific-python/repo-review@v0.11.0 with: plugins: sp-repo-review @@ -63,4 +63,4 @@ jobs: run: python -m pytest -ra --cov --cov-report=xml --cov-report=term --durations=20 - name: Upload coverage report - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v4.3.1 From 3ac5e891dfc09d64e2a8e7395dbaa56cb59d3295 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 23:50:13 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- .github/workflows/ci.yml | 4 +++- noxfile.py | 25 ++++++++----------------- src/zfit_pwa/__init__.py | 3 +-- src/zfit_pwa/compwa/variables.py | 8 ++++---- src/zfit_pwa/compwa/wrapper.py | 4 +--- tests/compwa/test_wrapper.py | 17 ++--------------- 6 files changed, 19 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c341840..9fd996d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,9 @@ jobs: run: python -m pip install .[test] - name: Test package - run: python -m pytest -ra --cov --cov-report=xml --cov-report=term --durations=20 + run: + python -m pytest -ra --cov --cov-report=xml --cov-report=term + --durations=20 - name: Upload coverage report uses: codecov/codecov-action@v4.3.1 diff --git a/noxfile.py b/noxfile.py index dd432f8..9788fb0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,9 +13,7 @@ @nox.session def lint(session: nox.Session) -> None: - """ - Run the linter. - """ + """Run the linter.""" session.install("pre-commit") session.run( "pre-commit", "run", "--all-files", "--show-diff-on-failure", *session.posargs @@ -24,9 +22,7 @@ def lint(session: nox.Session) -> None: @nox.session def pylint(session: nox.Session) -> None: - """ - Run PyLint. - """ + """Run PyLint.""" # This needs to be installed into the package environment, and is slower # than a pre-commit check session.install(".", "pylint") @@ -35,17 +31,16 @@ def pylint(session: nox.Session) -> None: @nox.session def tests(session: nox.Session) -> None: - """ - Run the unit and regular tests. - """ + """Run the unit and regular tests.""" session.install(".[test]") session.run("pytest", *session.posargs) @nox.session(reuse_venv=True) def docs(session: nox.Session) -> None: - """ - Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links. + """Build the docs. + + Pass "--serve" to serve. Pass "-b linkcheck" to check links. """ parser = argparse.ArgumentParser() @@ -86,9 +81,7 @@ def docs(session: nox.Session) -> None: @nox.session def build_api_docs(session: nox.Session) -> None: - """ - Build (regenerate) API docs. - """ + """Build (regenerate) API docs.""" session.install("sphinx") session.chdir("docs") @@ -105,9 +98,7 @@ def build_api_docs(session: nox.Session) -> None: @nox.session def build(session: nox.Session) -> None: - """ - Build an SDist and wheel. - """ + """Build an SDist and wheel.""" build_path = DIR.joinpath("build") if build_path.exists(): diff --git a/src/zfit_pwa/__init__.py b/src/zfit_pwa/__init__.py index 6169293..cd2924f 100644 --- a/src/zfit_pwa/__init__.py +++ b/src/zfit_pwa/__init__.py @@ -1,5 +1,4 @@ -""" -Copyright (c) 2024 Jonas Eschle. All rights reserved. +"""Copyright (c) 2024 Jonas Eschle. All rights reserved. zfit-pwa: Tools to adapt to Partial Wave Analysis packages """ diff --git a/src/zfit_pwa/compwa/variables.py b/src/zfit_pwa/compwa/variables.py index e2dcb48..961ce22 100644 --- a/src/zfit_pwa/compwa/variables.py +++ b/src/zfit_pwa/compwa/variables.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Mapping +from collections.abc import Mapping import numpy as np import pandas as pd @@ -19,8 +19,9 @@ def obs_from_frame(frame1, frame2=None, bufferfactor=0.01): if not isinstance(frame1, (Mapping, pd.DataFrame)) or not isinstance( frame2, (Mapping, pd.DataFrame) ): + msg = "frame1 and frame2 have to be either a mapping or a pandas DataFrame, or a zfit Data object. They are currently of type: " raise ValueError( - "frame1 and frame2 have to be either a mapping or a pandas DataFrame, or a zfit Data object. They are currently of type: ", + msg, type(frame1), type(frame2), ) @@ -38,5 +39,4 @@ def obs_from_frame(frame1, frame2=None, bufferfactor=0.01): ), ) ) - obsall = zfit.dimension.combine_spaces(*obs) - return obsall + return zfit.dimension.combine_spaces(*obs) diff --git a/src/zfit_pwa/compwa/wrapper.py b/src/zfit_pwa/compwa/wrapper.py index 1b247ef..80eaaaa 100644 --- a/src/zfit_pwa/compwa/wrapper.py +++ b/src/zfit_pwa/compwa/wrapper.py @@ -51,9 +51,7 @@ def _pdf(self, x, norm): @z.function(wraps="tensorwaves") def _jitted_unnormalized_pdf(self, data): - unnormalized_pdf = self.intensity(data) - - return unnormalized_pdf + return self.intensity(data) @z.function(wraps="tensorwaves") def _jitted_normalization(self, norm_sample): diff --git a/tests/compwa/test_wrapper.py b/tests/compwa/test_wrapper.py index 91ccb97..2d1ab67 100644 --- a/tests/compwa/test_wrapper.py +++ b/tests/compwa/test_wrapper.py @@ -39,9 +39,9 @@ def create_amplitude(): initial_state_mass=reaction.initial_state[-1].mass, final_state_masses={i: p.mass for i, p in reaction.final_state.items()}, ) - phsp_momenta = phsp_generator.generate(100_000, rng) + phsp_generator.generate(100_000, rng) - unfolded_expression = model.expression.doit() + model.expression.doit() return model, reaction @@ -93,19 +93,6 @@ def test_wrapper_simple(): data = helicity_transformer(data_momenta) data_frame = pd.DataFrame(data) phsp_frame = pd.DataFrame(phsp) - initial_parameters = { - R"C_{J/\psi(1S) \to {f_{0}(1500)}_{0} \gamma_{+1}; f_{0}(1500) \to \pi^{0}_{0} \pi^{0}_{0}}": ( - 1.0 - ), - "m_{f_{0}(500)}": 0.4, - "m_{f_{0}(980)}": 0.88, - "m_{f_{0}(1370)}": 1.22, - "m_{f_{0}(1500)}": 1.45, - "m_{f_{0}(1710)}": 1.83, - R"\Gamma_{f_{0}(500)}": 0.3, - R"\Gamma_{f_{0}(980)}": 0.1, - R"\Gamma_{f_{0}(1710)}": 0.3, - } # data conversion # phsp_zfit = zfit.Data.from_pandas(phsp_frame)