Skip to content

Commit e435c51

Browse files
authored
chore: bump boost-histogram min version to 1.5 (#631)
Require 1.5+, remove compat code for older versions. Signed-off-by: Henry Schreiner <[email protected]>
1 parent 3b8d5f3 commit e435c51

File tree

7 files changed

+19
-84
lines changed

7 files changed

+19
-84
lines changed

.github/CONTRIBUTING.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ specific jobs:
2323
```console
2424
$ nox -l # List all the defined sessions
2525
$ nox -s lint # Lint only
26-
$ nox -s tests-3.9 # Python 3.9 tests only
26+
$ nox -s tests-3.14 # Python 3.14 tests only
2727
$ nox -s docs -- serve # Build and serve the docs
2828
$ nox -s build # Make an SDist and wheel
2929
```
@@ -33,34 +33,24 @@ environment for each run. On Linux, it will run the `--mpl` tests. You can
3333
run the linux tests from anywhere with Docker:
3434

3535
```bash
36-
docker run --rm -v $PWD:/nox -w /nox -t quay.io/pypa/manylinux2014_x86_64:latest pipx run nox -s tests-3.9
36+
docker run --rm -v $PWD:/nox -w /nox -t quay.io/pypa/manylinux_2_28_x86_64:latest pipx run nox -s tests-3.9
3737
# Regenerate the MPL comparison images:
38-
docker run --rm -v $PWD:/nox -w /nox -t quay.io/pypa/manylinux2014_x86_64:latest pipx run nox -s regenerate
38+
docker run --rm -v $PWD:/nox -w /nox -t quay.io/pypa/manylinux_2_28_x86_64:latest pipx run nox -s regenerate
3939
```
4040

4141
### PyPI
4242

4343
For extended development, you can set up a development environment using PyPI.
4444

4545
```bash
46-
$ python3 -m venv venv
47-
$ source venv/bin/activate
48-
(venv)$ pip install -e .[dev]
46+
$ python3 -m venv .venv
47+
$ source .venv/bin/activate
48+
(venv)$ pip install -e . --group dev
4949
(venv)$ python -m ipykernel install --user --name hist
5050
```
5151

5252
You should have pip 10 or later.
5353

54-
### Conda
55-
56-
You can also set up a development environment using Conda. With conda, you can search some channels for development.
57-
58-
```bash
59-
$ conda env create -f dev-environment.yml -n hist
60-
$ conda activate hist
61-
(hist)$ python -m ipykernel install --name hist
62-
```
63-
6454
## Post setup
6555

6656
You should prepare pre-commit, which will help you by checking that commits

dev-environment.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ keywords = [
4040
]
4141
requires-python = ">=3.9"
4242
dependencies = [
43-
"boost-histogram>=1.3.1,<1.7",
43+
"boost-histogram>=1.5,<1.7",
4444
"histoprint>=2.2.0",
4545
'numpy>=1.19.3',
4646
'typing-extensions>=4;python_version<"3.11"',

src/hist/axis/__init__.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from collections.abc import Iterable
55
from typing import Any, Protocol
66

7-
import boost_histogram as bh
87
import boost_histogram.axis as bha
98

109
import hist
@@ -227,18 +226,11 @@ def __init__(
227226
__dict__: dict[str, Any] | None = None,
228227
) -> None:
229228
has_flow = flow if overflow is None else overflow
230-
if tuple(int(x) for x in bh.__version__.split(".")[:2]) < (1, 4):
231-
if not has_flow:
232-
msg = "Boost-histogram 1.4+ required for flowless Category axes"
233-
raise TypeError(msg)
234-
kwargs = {}
235-
else:
236-
kwargs = {"overflow": has_flow}
237229
super().__init__(
238230
categories,
239231
metadata=metadata,
240232
growth=growth,
241-
**kwargs,
233+
overflow=has_flow,
242234
__dict__=__dict__,
243235
)
244236
self._raw_metadata["name"] = name
@@ -261,18 +253,11 @@ def __init__(
261253
__dict__: dict[str, Any] | None = None,
262254
) -> None:
263255
has_flow = flow if overflow is None else overflow
264-
if tuple(int(x) for x in bh.__version__.split(".")[:2]) < (1, 4):
265-
if not has_flow:
266-
msg = "Boost-histogram 1.4+ required for flowless Category axes"
267-
raise TypeError(msg)
268-
kwargs = {}
269-
else:
270-
kwargs = {"overflow": has_flow}
271256
super().__init__(
272257
categories,
273258
metadata=metadata,
274259
growth=growth,
275-
**kwargs,
260+
overflow=has_flow,
276261
__dict__=__dict__,
277262
)
278263
self._raw_metadata["name"] = name

src/hist/basehist.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,6 @@ def __init__(
180180
self.name = name
181181
self.label = label
182182

183-
# Backport of storage_type from boost-histogram 1.3.2:
184-
if not hasattr(bh.Histogram, "storage_type"):
185-
186-
@property
187-
def storage_type(self) -> type[bh.storage.Storage]:
188-
return self._storage_type
189-
190183
def _generate_axes_(self) -> NamedAxesTuple:
191184
"""
192185
This is called to fill in the axes. Subclasses can override it if they need

tests/test_general.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import hist
1212
from hist import Hist, axis, storage
1313

14-
BHV = tuple(int(x) for x in bh.__version__.split(".")[:2])
15-
1614
# TODO: specify what error is raised
1715

1816

@@ -205,21 +203,17 @@ def test_general_fill_integer():
205203

206204
def test_general_fill_int_cat():
207205
h = Hist(
208-
axis.IntCategory(range(10), name="x", flow=BHV < (1, 4)),
209-
axis.IntCategory(range(10), name="y", overflow=BHV < (1, 4)),
206+
axis.IntCategory(range(10), name="x", flow=False),
207+
axis.IntCategory(range(10), name="y", overflow=False),
210208
axis.IntCategory(range(2), name="z"),
211209
).fill(
212210
x=[3, 3, 3, 4, 5, 5, 5],
213211
y=[3, 3, 4, 4, 4, 4, 4],
214212
z=[0, 0, 1, 1, 1, 1, 1],
215213
)
216214

217-
if BHV < (1, 4):
218-
assert h.axes[0].traits.overflow
219-
assert h.axes[1].traits.overflow
220-
else:
221-
assert not h.axes[0].traits.overflow
222-
assert not h.axes[1].traits.overflow
215+
assert not h.axes[0].traits.overflow
216+
assert not h.axes[1].traits.overflow
223217
assert h.axes[2].traits.overflow
224218

225219
z_one_only = h[{2: bh.loc(1)}]
@@ -235,21 +229,17 @@ def test_general_fill_int_cat():
235229

236230
def test_general_fill_str_cat():
237231
h = Hist(
238-
axis.StrCategory("FT", name="x", flow=BHV < (1, 4)),
239-
axis.StrCategory(list("FT"), name="y", overflow=BHV < (1, 4)),
232+
axis.StrCategory("FT", name="x", flow=False),
233+
axis.StrCategory(list("FT"), name="y", overflow=False),
240234
axis.StrCategory(["F", "T"], name="z"),
241235
).fill(
242236
["T", "T", "T", "T", "T", "F", "T"],
243237
["F", "T", "T", "F", "F", "T", "F"],
244238
["F", "F", "T", "T", "T", "T", "T"],
245239
)
246240

247-
if BHV < (1, 4):
248-
assert h.axes[0].traits.overflow
249-
assert h.axes[1].traits.overflow
250-
else:
251-
assert not h.axes[0].traits.overflow
252-
assert not h.axes[1].traits.overflow
241+
assert not h.axes[0].traits.overflow
242+
assert not h.axes[1].traits.overflow
253243
assert h.axes[2].traits.overflow
254244

255245
z_one_only = h[{2: bh.loc("T")}]
@@ -307,7 +297,7 @@ def test_general_access():
307297
h = Hist(
308298
axis.Regular(50, -5, 5, name="Norm", label="normal distribution"),
309299
axis.Regular(50, -5, 5, name="Unif", label="uniform distribution"),
310-
axis.StrCategory(["hi", "hello"], name="Greet", flow=BHV < (1, 4)),
300+
axis.StrCategory(["hi", "hello"], name="Greet", flow=False),
311301
axis.Boolean(name="Yes"),
312302
axis.Integer(0, 1000, name="Int"),
313303
).fill(

tests/test_serialization_uhi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
bhs = pytest.importorskip("boost_histogram.serialization")
1313

1414
BHV = packaging.version.Version(importlib.metadata.version("boost_histogram"))
15-
BHMETADATA = packaging.version.Version("1.6.1dev0") < BHV
15+
BHMETADATA = packaging.version.Version("1.6.1") <= BHV
1616

1717

1818
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)