Skip to content

Commit 9526332

Browse files
chrispap95lgraypre-commit-ci[bot]
authored
Fix cibuildwheel with patch (#131)
* Fix cibuildwheel with patch * Add link to PR for more info * add cp311, drop cp36 * formally drop python 3.6 * test in 3.7, 3.11 * Implement warning for exclusive jets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * More consistent naming for patches * Rename patch files Co-authored-by: Lindsey Gray <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3d2d3a8 commit 9526332

12 files changed

+110
-9
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
fail-fast: false
3535
matrix:
36-
python-version: ['3.6', '3.10']
36+
python-version: ['3.7', '3.11']
3737
runs-on: [ubuntu-latest] # , macos-latest
3838

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

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

6363
- name: Test package
6464
run: python -m pytest -vv -rs -Wd
@@ -72,10 +72,10 @@ jobs:
7272
with:
7373
submodules: recursive
7474

75-
- uses: pypa/cibuildwheel@v2.1.2
75+
- uses: pypa/cibuildwheel@v2.11.2
7676
env:
7777
CIBW_ARCHS: auto64
78-
CIBW_BUILD: cp310-*
78+
CIBW_BUILD: cp311-*
7979
CIBW_BUILD_VERBOSITY: 2
8080

8181
- name: Upload wheels

.github/workflows/wheels.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
python-build-version: ["cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp310-*"]
31+
python-build-version: ["cp37-*", "cp38-*", "cp39-*", "cp310-*", "cp311-*"]
3232
os: [ubuntu-latest] # , macos-latest
3333

3434
steps:
@@ -40,7 +40,7 @@ jobs:
4040
if: runner.os == 'macOS'
4141
run: brew install automake
4242

43-
- uses: pypa/cibuildwheel@v2.1.2
43+
- uses: pypa/cibuildwheel@v2.11.2
4444
env:
4545
CIBW_ARCHS: auto64
4646
CIBW_BUILD: ${{ matrix.python-build-version }}

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ graft tests
33
graft fastjet-core
44
graft pybind11
55
global-exclude .git .gitmodules
6-
include LICENSE README.md pyproject.toml setup.py setup.cfg patch.txt .clang-format
6+
include LICENSE README.md pyproject.toml setup.py setup.cfg patch_fastjet_i.txt patch_clustersequence.txt

patch_clustersequence.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- ClusterSequence_old.cc 2022-11-02 01:34:43.387347058 +0000
2+
+++ ClusterSequence.cc 2022-11-02 01:36:31.518212219 +0000
3+
@@ -1017,6 +1017,7 @@
4+
// Native algorithm that support it are: kt, ee_kt, Cambridge/Aachen,
5+
// genkt and ee_genkt (both with p>=0)
6+
// For plugins, we check Plugin::exclusive_sequence_meaningful()
7+
+ /*
8+
if (( _jet_def.jet_algorithm() != kt_algorithm) &&
9+
( _jet_def.jet_algorithm() != cambridge_algorithm) &&
10+
( _jet_def.jet_algorithm() != ee_kt_algorithm) &&
11+
@@ -1027,6 +1028,7 @@
12+
(!_jet_def.plugin()->exclusive_sequence_meaningful()))) {
13+
_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.");
14+
}
15+
+ */
16+
17+
18+
// calculate the point where we have to stop the clustering.
File renamed without changes.

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ before-all = [
2121
"tar --bzip2 -xf boost_1_80_0.tar.bz2",
2222
"mv boost_1_80_0/boost /usr/include/boost",
2323
]
24+
# Skip musllinux builds for the moment
25+
skip = "*-musllinux_*"

setup.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ install_requires =
3434
awkward>=1
3535
numpy>=1.13.3
3636
vector
37-
python_requires = >=3.6
37+
python_requires = >=3.7
3838
include_package_data = True
3939
package_dir =
4040
=src
@@ -64,6 +64,7 @@ ignore =
6464
docs/**
6565
.pre-commit-config.yaml
6666
.readthedocs.yml
67+
.clang-format
6768
src/*/version.py
6869

6970
[tool:isort]

setup.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ def build_extensions(self):
5656
# Patch for FastJet core version 3.4.0
5757
# To be removed when https://gitlab.com/fastjet/fastjet/-/merge_requests/1 is merged upstream
5858
subprocess.run(
59-
["patch", "pyinterface/fastjet.i", DIR / "patch.txt"],
59+
["patch", "pyinterface/fastjet.i", DIR / "patch_fastjet_i.txt"],
60+
cwd=FASTJET,
61+
)
62+
63+
# Patch for segfault of LimitedWarning
64+
# For more info see https://github.com/scikit-hep/fastjet/pull/131
65+
subprocess.run(
66+
["patch", "src/ClusterSequence.cc", DIR / "patch_clustersequence.txt"],
6067
cwd=FASTJET,
6168
)
6269

src/fastjet/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -547,3 +547,8 @@ class multi_inheritor(
547547
): # class that inherits both the custom ClusterSequence and swig ClusterSequence and acts as a trampoline
548548
def __init__(self):
549549
pass
550+
551+
552+
def formatwarning(message, category, filename, lineno, line=None):
553+
"""Make warnings resemble the ones from fastjet-core"""
554+
return f"{category.__name__}: {message}\n"

src/fastjet/_generalevent.py

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import awkward as ak
24
import numpy as np
35

@@ -555,6 +557,25 @@ def replace(self, layout, cluster, level):
555557
else:
556558
raise AssertionError(layout)
557559

560+
def _warn_for_exclusive(self):
561+
if (
562+
self.jetdef
563+
not in [
564+
fastjet.kt_algorithm,
565+
fastjet.cambridge_algorithm,
566+
fastjet.ee_kt_algorithm,
567+
fastjet.plugin_algorithm,
568+
]
569+
) and (
570+
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
571+
or self.jetdef.extra_param() < 0
572+
):
573+
warnings.formatwarning = fastjet.formatwarning
574+
warnings.warn(
575+
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
576+
)
577+
return
578+
558579
def inclusive_jets(self, min_pt):
559580
self._out = []
560581
self._input_flag = 0
@@ -727,6 +748,7 @@ def jets(self):
727748
return res
728749

729750
def exclusive_jets(self, n_jets, dcut):
751+
self._warn_for_exclusive()
730752
self._out = []
731753
self._input_flag = 0
732754
for i in range(len(self._clusterable_level)):
@@ -764,6 +786,7 @@ def exclusive_jets(self, n_jets, dcut):
764786
return res
765787

766788
def exclusive_jets_ycut(self, ycut):
789+
self._warn_for_exclusive()
767790
self._out = []
768791
self._input_flag = 0
769792
for i in range(len(self._clusterable_level)):

src/fastjet/_multievent.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import awkward as ak
24
import numpy as np
35

@@ -61,6 +63,25 @@ def single_to_jagged(self, array):
6163
)
6264
return single
6365

66+
def _warn_for_exclusive(self):
67+
if (
68+
self.jetdef
69+
not in [
70+
fastjet.kt_algorithm,
71+
fastjet.cambridge_algorithm,
72+
fastjet.ee_kt_algorithm,
73+
fastjet.plugin_algorithm,
74+
]
75+
) and (
76+
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
77+
or self.jetdef.extra_param() < 0
78+
):
79+
warnings.formatwarning = fastjet.formatwarning
80+
warnings.warn(
81+
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
82+
)
83+
return
84+
6485
def inclusive_jets(self, min_pt):
6586
np_results = self._results.to_numpy(min_pt)
6687
of = np_results[-1]
@@ -102,6 +123,7 @@ def unclustered_particles(self):
102123
)
103124

104125
def exclusive_jets(self, n_jets, dcut):
126+
self._warn_for_exclusive()
105127
of = 0
106128
np_results = 0
107129
if n_jets == 0:

src/fastjet/_singleevent.py

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import awkward as ak
24
import numpy as np
35

@@ -66,6 +68,25 @@ def single_to_jagged(self, array):
6668
)
6769
return single
6870

71+
def _warn_for_exclusive(self):
72+
if (
73+
self.jetdef
74+
not in [
75+
fastjet.kt_algorithm,
76+
fastjet.cambridge_algorithm,
77+
fastjet.ee_kt_algorithm,
78+
fastjet.plugin_algorithm,
79+
]
80+
) and (
81+
(self.jetdef not in [fastjet.kt_algorithm, fastjet.cambridge_algorithm])
82+
or self.jetdef.extra_param() < 0
83+
):
84+
warnings.formatwarning = fastjet.formatwarning
85+
warnings.warn(
86+
"dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."
87+
)
88+
return
89+
6990
def inclusive_jets(self, min_pt):
7091
np_results = self._results.to_numpy(min_pt)
7192
return ak.Array(
@@ -99,6 +120,7 @@ def unclustered_particles(self):
99120
)
100121

101122
def exclusive_jets(self, n_jets, dcut):
123+
self._warn_for_exclusive()
102124
np_results = 0
103125
if n_jets == 0:
104126
raise ValueError("Njets cannot be 0") from None
@@ -123,6 +145,7 @@ def exclusive_jets(self, n_jets, dcut):
123145
)
124146

125147
def exclusive_jets_ycut(self, ycut):
148+
self._warn_for_exclusive()
126149
np_results = self._results.to_numpy_exclusive_ycut(ycut)
127150
return ak.Array(
128151
ak.layout.RecordArray(

0 commit comments

Comments
 (0)