Skip to content

Commit 55fe65c

Browse files
authored
fix: support boost-histogram 1.6, add Python 3.14 to ci (#618)
Supports boost-histogram 1.6. --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 1fc1608 commit 55fe65c

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- "3.11"
3636
- "3.12"
3737
- "3.13"
38+
- "3.14"
3839

3940
name: Check Python ${{ matrix.python-version }}
4041
steps:
@@ -52,6 +53,11 @@ jobs:
5253
run: uv venv
5354

5455
- name: Install package
56+
if: matrix.python-version == '3.14'
57+
run: uv pip install -e ".[test]"
58+
59+
- name: Install package (dask)
60+
if: matrix.python-version != '3.14'
5561
run: uv pip install -e ".[test,dask]"
5662

5763
- name: Test package

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ classifiers = [
2222
"Programming Language :: Python :: 3.11",
2323
"Programming Language :: Python :: 3.12",
2424
"Programming Language :: Python :: 3.13",
25+
"Programming Language :: Python :: 3.14",
2526
"Topic :: Scientific/Engineering",
2627
"Topic :: Scientific/Engineering :: Information Analysis",
2728
"Topic :: Scientific/Engineering :: Mathematics",
@@ -35,7 +36,7 @@ keywords = [
3536
]
3637
requires-python = ">=3.9"
3738
dependencies = [
38-
"boost-histogram>=1.3.1,<1.6",
39+
"boost-histogram>=1.3.1,<1.7",
3940
"histoprint>=2.2.0",
4041
'numpy>=1.19.3',
4142
'typing-extensions>=4;python_version<"3.11"',

src/hist/axestuple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def name(self) -> tuple[str]:
5050
def name(self, values: Iterable[str]) -> None:
5151
# strict = True from Python 3.10
5252
for ax, val in zip(self, values, strict=True):
53-
ax._ax.metadata["name"] = val
53+
ax._raw_metadata["name"] = val
5454

5555
disallowed_names = {"weight", "sample", "threads"}
5656
for ax in self:

src/hist/axis/__init__.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def __dir__() -> tuple[str, ...]:
3232

3333

3434
class CoreAxisProtocol(Protocol):
35-
metadata: dict[str, Any]
35+
metadata: dict[str, Any] # boost-histogram < 1.6
36+
raw_metadata: dict[str, Any]
3637

3738

3839
class AxisProtocol(Protocol):
@@ -44,6 +45,9 @@ def name(self) -> str: ...
4445
label: str
4546
_ax: CoreAxisProtocol
4647

48+
@property
49+
def _raw_metadata(self) -> dict[str, Any]: ...
50+
4751

4852
class AxesMixin:
4953
__slots__ = ()
@@ -52,23 +56,30 @@ class AxesMixin:
5256
def __init_subclass__(cls, **kwargs: Any) -> None:
5357
super().__init_subclass__(**kwargs)
5458

59+
@property
60+
def _raw_metadata(self: AxisProtocol) -> dict[str, Any]:
61+
# boost-histogram < 1.6
62+
if hasattr(self._ax, "metadata"):
63+
return self._ax.metadata
64+
return self._ax.raw_metadata
65+
5566
@property
5667
def name(self: AxisProtocol) -> str:
5768
"""
5869
Get the name for the Regular axis
5970
"""
60-
return typing.cast(str, self._ax.metadata.get("name", ""))
71+
return typing.cast(str, self._raw_metadata.get("name", ""))
6172

6273
@property
6374
def label(self: AxisProtocol) -> str:
6475
"""
6576
Get or set the label for the Regular axis
6677
"""
67-
return self._ax.metadata.get("label", "") or self.name
78+
return self._raw_metadata.get("label", "") or self.name
6879

6980
@label.setter
7081
def label(self: AxisProtocol, value: str) -> None:
71-
self._ax.metadata["label"] = value
82+
self._raw_metadata["label"] = value
7283

7384
def _repr_args_(self: AxisProtocol) -> list[str]:
7485
"""
@@ -117,7 +128,7 @@ def __init__(
117128
transform=transform,
118129
__dict__=__dict__,
119130
)
120-
self._ax.metadata["name"] = name
131+
self._raw_metadata["name"] = name
121132
self.label: str = label
122133

123134

@@ -136,7 +147,7 @@ def __init__(
136147
metadata=metadata,
137148
__dict__=__dict__,
138149
)
139-
self._ax.metadata["name"] = name
150+
self._raw_metadata["name"] = name
140151
self.label: str = label
141152

142153

@@ -166,7 +177,7 @@ def __init__(
166177
circular=circular,
167178
__dict__=__dict__,
168179
)
169-
self._ax.metadata["name"] = name
180+
self._raw_metadata["name"] = name
170181
self.label: str = label
171182

172183

@@ -198,7 +209,7 @@ def __init__(
198209
circular=circular,
199210
__dict__=__dict__,
200211
)
201-
self._ax.metadata["name"] = name
212+
self._raw_metadata["name"] = name
202213
self.label: str = label
203214

204215

@@ -232,7 +243,7 @@ def __init__(
232243
**kwargs,
233244
__dict__=__dict__,
234245
)
235-
self._ax.metadata["name"] = name
246+
self._raw_metadata["name"] = name
236247
self.label: str = label
237248

238249

@@ -266,5 +277,5 @@ def __init__(
266277
**kwargs,
267278
__dict__=__dict__,
268279
)
269-
self._ax.metadata["name"] = name
280+
self._raw_metadata["name"] = name
270281
self.label: str = label

0 commit comments

Comments
 (0)