Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cibuildwheel with patch #131

Merged
merged 11 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.10']
python-version: ['3.7', '3.11']
runs-on: [ubuntu-latest] # , macos-latest

# include:
Expand All @@ -58,7 +58,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev swig autoconf libtool

- name: Install package
run: python -m pip install .[test] -v
run: python -m pip install '.[test]' -v

- name: Test package
run: python -m pytest -vv -rs -Wd
Expand All @@ -72,10 +72,10 @@ jobs:
with:
submodules: recursive

- uses: pypa/cibuildwheel@v2.1.2
- uses: pypa/cibuildwheel@v2.11.2
env:
CIBW_ARCHS: auto64
CIBW_BUILD: cp310-*
CIBW_BUILD: cp311-*
CIBW_BUILD_VERBOSITY: 2

- name: Upload wheels
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-build-version: ["cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp310-*"]
python-build-version: ["cp37-*", "cp38-*", "cp39-*", "cp310-*", "cp311-*"]
os: [ubuntu-latest] # , macos-latest

steps:
Expand All @@ -40,7 +40,7 @@ jobs:
if: runner.os == 'macOS'
run: brew install automake

- uses: pypa/cibuildwheel@v2.1.2
- uses: pypa/cibuildwheel@v2.11.2
env:
CIBW_ARCHS: auto64
CIBW_BUILD: ${{ matrix.python-build-version }}
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ graft tests
graft fastjet-core
graft pybind11
global-exclude .git .gitmodules
include LICENSE README.md pyproject.toml setup.py setup.cfg patch.txt .clang-format
include LICENSE README.md pyproject.toml setup.py setup.cfg patch_fastjet_i.txt patch_clustersequence.txt
18 changes: 18 additions & 0 deletions patch_clustersequence.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- ClusterSequence_old.cc 2022-11-02 01:34:43.387347058 +0000
+++ ClusterSequence.cc 2022-11-02 01:36:31.518212219 +0000
@@ -1017,6 +1017,7 @@
// Native algorithm that support it are: kt, ee_kt, Cambridge/Aachen,
// genkt and ee_genkt (both with p>=0)
// For plugins, we check Plugin::exclusive_sequence_meaningful()
+ /*
if (( _jet_def.jet_algorithm() != kt_algorithm) &&
( _jet_def.jet_algorithm() != cambridge_algorithm) &&
( _jet_def.jet_algorithm() != ee_kt_algorithm) &&
@@ -1027,6 +1028,7 @@
(!_jet_def.plugin()->exclusive_sequence_meaningful()))) {
_exclusive_warnings.warn("dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care.");
}
+ */


// calculate the point where we have to stop the clustering.
File renamed without changes.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ before-all = [
"tar --bzip2 -xf boost_1_80_0.tar.bz2",
"mv boost_1_80_0/boost /usr/include/boost",
]
# Skip musllinux builds for the moment
skip = "*-musllinux_*"
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ install_requires =
awkward>=1
numpy>=1.13.3
vector
python_requires = >=3.6
python_requires = >=3.7
include_package_data = True
package_dir =
=src
Expand Down Expand Up @@ -64,6 +64,7 @@ ignore =
docs/**
.pre-commit-config.yaml
.readthedocs.yml
.clang-format
src/*/version.py

[tool:isort]
Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ def build_extensions(self):
# Patch for FastJet core version 3.4.0
# To be removed when https://gitlab.com/fastjet/fastjet/-/merge_requests/1 is merged upstream
subprocess.run(
["patch", "pyinterface/fastjet.i", DIR / "patch.txt"],
["patch", "pyinterface/fastjet.i", DIR / "patch_fastjet_i.txt"],
cwd=FASTJET,
)

# Patch for segfault of LimitedWarning
# For more info see https://github.com/scikit-hep/fastjet/pull/131
subprocess.run(
["patch", "src/ClusterSequence.cc", DIR / "patch_clustersequence.txt"],
cwd=FASTJET,
)

Expand Down
5 changes: 5 additions & 0 deletions src/fastjet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,8 @@ class multi_inheritor(
): # class that inherits both the custom ClusterSequence and swig ClusterSequence and acts as a trampoline
def __init__(self):
pass


def formatwarning(message, category, filename, lineno, line=None):
"""Make warnings resemble the ones from fastjet-core"""
return f"{category.__name__}: {message}\n"
23 changes: 23 additions & 0 deletions src/fastjet/_generalevent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import awkward as ak
import numpy as np

Expand Down Expand Up @@ -555,6 +557,25 @@ def replace(self, layout, cluster, level):
else:
raise AssertionError(layout)

def _warn_for_exclusive(self):
if (
self.jetdef
not in [
fastjet.kt_algorithm,
fastjet.cambridge_algorithm,
fastjet.ee_kt_algorithm,
fastjet.plugin_algorithm,
]
) and (
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
or self.jetdef.extra_param() < 0
):
warnings.formatwarning = fastjet.formatwarning
warnings.warn(
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
)
return

def inclusive_jets(self, min_pt):
self._out = []
self._input_flag = 0
Expand Down Expand Up @@ -727,6 +748,7 @@ def jets(self):
return res

def exclusive_jets(self, n_jets, dcut):
self._warn_for_exclusive()
self._out = []
self._input_flag = 0
for i in range(len(self._clusterable_level)):
Expand Down Expand Up @@ -764,6 +786,7 @@ def exclusive_jets(self, n_jets, dcut):
return res

def exclusive_jets_ycut(self, ycut):
self._warn_for_exclusive()
self._out = []
self._input_flag = 0
for i in range(len(self._clusterable_level)):
Expand Down
22 changes: 22 additions & 0 deletions src/fastjet/_multievent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import awkward as ak
import numpy as np

Expand Down Expand Up @@ -61,6 +63,25 @@ def single_to_jagged(self, array):
)
return single

def _warn_for_exclusive(self):
if (
self.jetdef
not in [
fastjet.kt_algorithm,
fastjet.cambridge_algorithm,
fastjet.ee_kt_algorithm,
fastjet.plugin_algorithm,
]
) and (
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
or self.jetdef.extra_param() < 0
):
warnings.formatwarning = fastjet.formatwarning
warnings.warn(
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
)
return

def inclusive_jets(self, min_pt):
np_results = self._results.to_numpy(min_pt)
of = np_results[-1]
Expand Down Expand Up @@ -102,6 +123,7 @@ def unclustered_particles(self):
)

def exclusive_jets(self, n_jets, dcut):
self._warn_for_exclusive()
of = 0
np_results = 0
if n_jets == 0:
Expand Down
23 changes: 23 additions & 0 deletions src/fastjet/_singleevent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import awkward as ak
import numpy as np

Expand Down Expand Up @@ -66,6 +68,25 @@ def single_to_jagged(self, array):
)
return single

def _warn_for_exclusive(self):
if (
self.jetdef
not in [
fastjet.kt_algorithm,
fastjet.cambridge_algorithm,
fastjet.ee_kt_algorithm,
fastjet.plugin_algorithm,
]
) and (
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
or self.jetdef.extra_param() < 0
):
warnings.formatwarning = fastjet.formatwarning
warnings.warn(
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
)
return

def inclusive_jets(self, min_pt):
np_results = self._results.to_numpy(min_pt)
return ak.Array(
Expand Down Expand Up @@ -99,6 +120,7 @@ def unclustered_particles(self):
)

def exclusive_jets(self, n_jets, dcut):
self._warn_for_exclusive()
np_results = 0
if n_jets == 0:
raise ValueError("Njets cannot be 0") from None
Expand All @@ -123,6 +145,7 @@ def exclusive_jets(self, n_jets, dcut):
)

def exclusive_jets_ycut(self, ycut):
self._warn_for_exclusive()
np_results = self._results.to_numpy_exclusive_ycut(ycut)
return ak.Array(
ak.layout.RecordArray(
Expand Down