Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import nox

DIR = Path(__file__).parent.resolve()
ALL_PYTHON = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
ALL_PYTHON = ["3.10", "3.11", "3.12", "3.13", "3.14"]

nox.needs_version = ">=2024.3.2"
nox.options.sessions = ["lint", "tests"]
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ authors = [
description = "Histogramming tools on CUDA."
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.8"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
Expand All @@ -25,12 +25,11 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
Expand Down Expand Up @@ -99,7 +98,7 @@ report.exclude_also = [

[tool.mypy]
files = ["src", "tests"]
python_version = "3.8"
python_version = "3.10"
warn_unused_configs = true
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
Expand Down Expand Up @@ -166,7 +165,7 @@ isort.required-imports = ["from __future__ import annotations"]


[tool.pylint]
py-version = "3.8"
py-version = "3.10"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
Expand Down
15 changes: 9 additions & 6 deletions src/cuda_histogram/axis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import functools
import numbers
import warnings
from typing import Iterable
from collections.abc import Iterable

import awkward
import cupy
Expand Down Expand Up @@ -414,7 +414,7 @@ class Bin(DenseAxis):

def __init__(self, n_or_arr, lo=None, hi=None, *, name="", label=""):
self._lazy_intervals = None
if isinstance(n_or_arr, (list, np.ndarray, cupy.ndarray)):
if isinstance(n_or_arr, list | np.ndarray | cupy.ndarray):
self._uniform = False
self._bins = cupy.array(n_or_arr, dtype="d")
if not all(np.sort(self._bins) == self._bins):
Expand Down Expand Up @@ -454,7 +454,10 @@ def _intervals(self):
self._lazy_intervals = [
Interval(low, high, bin)
for low, high, bin in zip(
self._interval_bins[:-1], self._interval_bins[1:], self._bin_names
self._interval_bins[:-1],
self._interval_bins[1:],
self._bin_names,
strict=False,
)
]
return self._lazy_intervals
Expand Down Expand Up @@ -485,7 +488,7 @@ def index(self, identifier):
The integer range includes flow bins: ``0 = underflow, n+1 = overflow, n+2 = nanflow``
"""
isarray = isinstance(
identifier, (awkward.Array, cupy.ndarray, np.ndarray, list)
identifier, awkward.Array | cupy.ndarray | np.ndarray | list
)
if isarray or isinstance(identifier, numbers.Number):
identifier = awkward.to_cupy(identifier) # cupy.asarray(identifier)
Expand All @@ -506,7 +509,7 @@ def index(self, identifier):
self._bins + 1,
)

if isinstance(idx, (cupy.ndarray, np.ndarray)):
if isinstance(idx, cupy.ndarray | np.ndarray):
_replace_nans(
self.size - 1,
idx if idx.dtype.kind == "f" else idx.astype(cupy.float32),
Expand Down Expand Up @@ -630,7 +633,7 @@ def size(self):
"""Number of bins"""
return (
self._bins
if isinstance(self._bins, (int, np.integer, cupy.integer))
if isinstance(self._bins, int | np.integer | cupy.integer)
else len(self._bins)
)

Expand Down
16 changes: 9 additions & 7 deletions src/cuda_histogram/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ def _init_sumw2(self):
# TODO: should allow better indexing (UHI)
def __getitem__(self, keys):
if isinstance(keys, slice) and not all(
isinstance(s, (int, float)) or s is None
isinstance(s, int | float) or s is None
for s in [keys.start, keys.stop, keys.step]
):
raise ValueError("use to_boost/to_hist to access other UHI functionalities")
if not isinstance(keys, slice) and not isinstance(keys, (int, float, tuple)):
if not isinstance(keys, slice) and not isinstance(keys, int | float | tuple):
raise ValueError("use to_boost/to_hist to access other UHI functionalities")
if not isinstance(keys, tuple):
keys = (keys,)
Expand All @@ -161,7 +161,7 @@ def __getitem__(self, keys):
sparse_idx = []
dense_idx = []
new_dims = []
for s, ax in zip(keys, self._axes):
for s, ax in zip(keys, self._axes, strict=False):
if isinstance(ax, SparseAxis):
sparse_idx.append(ax._ireduce(s))
new_dims.append(ax)
Expand All @@ -180,7 +180,9 @@ def dense_op(array):
if self._sumw2 is not None:
out._init_sumw2()
for sparse_key in self._sumw:
if not all(k in idx for k, idx in zip(sparse_key, sparse_idx)):
if not all(
k in idx for k, idx in zip(sparse_key, sparse_idx, strict=False)
):
continue
if sparse_key in out._sumw:
out._sumw[sparse_key] += dense_op(self._sumw[sparse_key])
Expand All @@ -203,7 +205,7 @@ def fill(self, *args, weight=None):
weight : cupy.ndarray
Provide weights.
"""
if not all(isinstance(a, (cupy.ndarray, str)) for a in args):
if not all(isinstance(a, cupy.ndarray | str) for a in args):
raise TypeError("pass CuPy arrays")
if weight is not None and not isinstance(weight, cupy.ndarray):
raise TypeError("pass CuPy arrays")
Expand All @@ -216,7 +218,7 @@ def fill(self, *args, weight=None):

sparse_key = tuple(
d.index(value)
for d, value in zip(self._axes, args)
for d, value in zip(self._axes, args, strict=False)
if isinstance(d, SparseAxis)
)

Expand All @@ -232,7 +234,7 @@ def fill(self, *args, weight=None):
if self.dense_dim() > 0:
dense_indices = tuple(
cupy.asarray(d.index(value))
for d, value in zip(self._axes, args)
for d, value in zip(self._axes, args, strict=False)
if isinstance(d, DenseAxis)
)
xy = cupy.atleast_1d(
Expand Down
Loading