From 3646408ce52aa6fa4d3ebacb7e6a9e2cb5b49248 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:06:14 +0000 Subject: [PATCH 1/5] chore: update 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.5.7 → v0.6.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.1) --- .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 1d056200..11d49f51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.7" + rev: "v0.6.1" hooks: - id: ruff args: ["--fix", "--show-fixes"] From f2988b259f283370fc47df3365c4eaab7a9f2730 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:09:24 +0000 Subject: [PATCH 2/5] style: pre-commit fixes --- docs/usage/intro.ipynb | 42 ++++++++++++++-------------------- tests/test_compute_features.py | 2 +- tests/test_notebooks.py | 2 +- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/docs/usage/intro.ipynb b/docs/usage/intro.ipynb index 54164e0e..f86022cf 100644 --- a/docs/usage/intro.ipynb +++ b/docs/usage/intro.ipynb @@ -34,6 +34,8 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import numbers\n", "\n", "import awkward as ak # at least version 1.2.0rc5\n", @@ -3249,12 +3251,12 @@ "v1 = vector.obj(x=1, y=2, z=3)\n", "v2 = vector.obj(x=1, y=2)\n", "\n", - "print(v1 - v2.like(v1)) # transforms v2 to v1's coordinate system (imputes z=0)\n", - "print(v1.like(v2) - v2) # transforms v1 to v2's coordinate system (removes z)\n", - "print(v1 - v2.to_xyz()) # transforms v2 to xyz coordinates (imputes z=0)\n", - "print(v1.to_xy() - v2) # transforms v1 to xy coordinates (removes z)\n", - "print(v1 - v2.to_Vector3D(z=3)) # transforms v2 to 3D (imputes z=3)\n", - "print(v1.to_Vector2D() - v2) # transforms v1 to 2D (removes z)" + "print(v1 - v2.like(v1)) # transforms v2 to v1's coordinate system (imputes z=0)\n", + "print(v1.like(v2) - v2) # transforms v1 to v2's coordinate system (removes z)\n", + "print(v1 - v2.to_xyz()) # transforms v2 to xyz coordinates (imputes z=0)\n", + "print(v1.to_xy() - v2) # transforms v1 to xy coordinates (removes z)\n", + "print(v1 - v2.to_Vector3D(z=3)) # transforms v2 to 3D (imputes z=3)\n", + "print(v1.to_Vector2D() - v2) # transforms v1 to 2D (removes z)" ] }, { @@ -3573,10 +3575,12 @@ "class TwoVector(vector.backends.awkward.MomentumAwkward2D):\n", " pass\n", "\n", + "\n", "@ak.mixin_class(behavior)\n", "class ThreeVector(vector.backends.awkward.MomentumAwkward3D):\n", " pass\n", "\n", + "\n", "# required for transforming vectors\n", "# the class names must always end with \"Array\"\n", "TwoVectorArray.ProjectionClass2D = TwoVectorArray # noqa: F821\n", @@ -3857,10 +3861,10 @@ "outputs": [], "source": [ "_binary_dispatch_cls = {\n", - " \"TwoVector\": TwoVector,\n", - " \"ThreeVector\": ThreeVector,\n", - " \"LorentzVector\": LorentzVector,\n", - " }\n", + " \"TwoVector\": TwoVector,\n", + " \"ThreeVector\": ThreeVector,\n", + " \"LorentzVector\": LorentzVector,\n", + "}\n", "_rank = [TwoVector, ThreeVector, LorentzVector]\n", "\n", "for lhs, lhs_to in _binary_dispatch_cls.items():\n", @@ -3951,21 +3955,9 @@ "metadata": {}, "outputs": [], "source": [ - "behavior.update(\n", - " ak._util.copy_behaviors(\n", - " \"Vector2D\", \"TwoVector\", behavior\n", - " )\n", - ")\n", - "behavior.update(\n", - " ak._util.copy_behaviors(\n", - " \"Vector3D\", \"ThreeVector\", behavior\n", - " )\n", - ")\n", - "behavior.update(\n", - " ak._util.copy_behaviors(\n", - " \"Momentum4D\", \"LorentzVector\", behavior\n", - " )\n", - ")" + "behavior.update(ak._util.copy_behaviors(\"Vector2D\", \"TwoVector\", behavior))\n", + "behavior.update(ak._util.copy_behaviors(\"Vector3D\", \"ThreeVector\", behavior))\n", + "behavior.update(ak._util.copy_behaviors(\"Momentum4D\", \"LorentzVector\", behavior))" ] }, { diff --git a/tests/test_compute_features.py b/tests/test_compute_features.py index e5185771..844167e3 100644 --- a/tests/test_compute_features.py +++ b/tests/test_compute_features.py @@ -99,7 +99,7 @@ @pytest.mark.skipif(is_unsupported, reason=unsupported_message) -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.parametrize("signature", functions.keys()) def test(signature): analyze_function(functions[signature]) diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index bdaed1cc..f06a4d42 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -7,7 +7,7 @@ import pytest -@pytest.fixture() +@pytest.fixture def common_kwargs(tmpdir): outputnb = tmpdir.join("output.ipynb") return { From 4592200713f5d7dce484f93011e48b537c16e5bd Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 26 Aug 2024 15:03:36 +0100 Subject: [PATCH 3/5] fix ruff on notebooks --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 474d6fbd..3f9af239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,6 +137,9 @@ isort.required-imports = [ "tests/*" = [ "T20", ] +"docs/usage/intro.ipynb" = [ + "T20", +] "src/vector/backends/_numba_object.py" = [ "PGH003", ] From 4c8044d6befd4f082ff19f8e7c6f627efe328e37 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 26 Aug 2024 15:16:28 +0100 Subject: [PATCH 4/5] numpy < 2.1 for numba --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3f9af239..3c12495b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dynamic = [ "version", ] dependencies = [ - "numpy>=1.13.3", + "numpy>=1.13.3,<2.1", "packaging>=19", ] optional-dependencies.awkward = [ From 75c9c9e03df7b282a178da896896e8e2f9d342ec Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 26 Aug 2024 15:19:21 +0100 Subject: [PATCH 5/5] Use numpy < 2.1 in ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b00f3c6..1a9efe72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: run: python -m pip install -e .[dev] - name: Install awkward v2 - run: python -m pip install -U awkward numpy + run: python -m pip install -U awkward "numpy<2.1" - name: Run doctests on Python 3.11 with awkward v2.x if: matrix.python-version == 3.11