diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index abb1a549..99168510 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - id: mypy files: ^src args: [] - additional_dependencies: ["numpy~=1.26.0", "matplotlib>=3.4", "boost-histogram~=1.4.0", "uhi~=0.3.1", "pandas-stubs>=2.0.1.230501"] + additional_dependencies: ["numpy~=2.2.0", "matplotlib>=3.4", "boost-histogram~=1.5.0", "uhi~=0.3.1", "pandas-stubs>=2.0.1.230501"] - repo: https://github.com/codespell-project/codespell rev: v2.3.0 diff --git a/src/hist/basehist.py b/src/hist/basehist.py index 3d0a99b7..1bd97689 100644 --- a/src/hist/basehist.py +++ b/src/hist/basehist.py @@ -196,11 +196,11 @@ def from_columns( for ax in axes: if isinstance(ax, str): assert ax in data, f"{ax} must be present in data={list(data)}" - cats = set(data[ax]) # type: ignore[arg-type] + cats = set(data[ax]) if all(isinstance(a, str) for a in cats): - axes_list.append(hist.axis.StrCategory(sorted(cats), name=ax)) # type: ignore[arg-type] + axes_list.append(hist.axis.StrCategory(sorted(cats), name=ax)) elif all(isinstance(a, int) for a in cats): - axes_list.append(hist.axis.IntCategory(sorted(cats), name=ax)) # type: ignore[arg-type] + axes_list.append(hist.axis.IntCategory(sorted(cats), name=ax)) else: raise TypeError( f"{ax} must be all int or strings if axis not given" @@ -214,7 +214,7 @@ def from_columns( self = cls(*axes_list, storage=storage) data_list = {x.name: data[x.name] for x in axes_list} - self.fill(**data_list, weight=weight_arr) # type: ignore[arg-type] + self.fill(**data_list, weight=weight_arr) return self def project(self, *args: int | str) -> Self | float | bh.accumulators.Accumulator: diff --git a/src/hist/interop.py b/src/hist/interop.py index 3dbc54ce..e77422ca 100644 --- a/src/hist/interop.py +++ b/src/hist/interop.py @@ -99,7 +99,7 @@ def broadcast_and_flatten( try: arrays.append(np.asarray(arg)) except (TypeError, ValueError): - return NotImplemented + return NotImplemented # type: ignore[no-any-return] return tuple(np.ravel(x) for x in np.broadcast_arrays(*arrays)) @@ -126,6 +126,6 @@ def broadcast_and_flatten( try: arrays.append(np.asarray(arg)) except (TypeError, ValueError): - return NotImplemented + return NotImplemented # type: ignore[no-any-return] return tuple(np.ravel(x) for x in np.broadcast_arrays(*arrays)) diff --git a/src/hist/intervals.py b/src/hist/intervals.py index 50c7d27f..49fd35ff 100644 --- a/src/hist/intervals.py +++ b/src/hist/intervals.py @@ -107,7 +107,7 @@ def clopper_pearson_interval( interval = np.stack((interval_min, interval_max)) interval[0, num == 0.0] = 0.0 interval[1, num == denom] = 1.0 - return interval # type: ignore[no-any-return] + return interval def ratio_uncertainty( diff --git a/src/hist/plot.py b/src/hist/plot.py index 9690660b..4e6df3ff 100644 --- a/src/hist/plot.py +++ b/src/hist/plot.py @@ -460,7 +460,7 @@ def plot_ratio_array( valid_ratios + ratio_uncert[1][valid_ratios_idx], ] ) - max_delta = np.amax(np.abs(extrema - central_value)) + max_delta: float = np.amax(np.abs(extrema - central_value)) ratio_extrema = np.abs(max_delta + central_value) _alpha = 2.0 diff --git a/src/hist/svgplots.py b/src/hist/svgplots.py index c7b9b64e..2e447474 100644 --- a/src/hist/svgplots.py +++ b/src/hist/svgplots.py @@ -70,7 +70,7 @@ def svg_hist_1d(h: hist.BaseHist) -> svg: (edges,) = h.axes.edges norm_edges = (edges - edges[0]) / (edges[-1] - edges[0]) density = h.density() - max_dens = np.amax(density) or 1 + max_dens: float = np.amax(density) norm_vals: np.typing.NDArray[Any] = density / max_dens arr: np.typing.NDArray[np.float64] = np.empty( @@ -121,7 +121,7 @@ def svg_hist_1d_c(h: hist.BaseHist) -> svg: (edges,) = h.axes.edges norm_edges = (edges - edges[0]) / (edges[-1] - edges[0]) * np.pi * 2 density = h.density() - max_dens = np.amax(density) or 1 + max_dens: float = np.amax(density) norm_vals: np.typing.NDArray[Any] = density / max_dens arr: np.typing.NDArray[np.float64] = np.empty((2, len(norm_vals) * 2), dtype=float) @@ -155,7 +155,7 @@ def svg_hist_2d(h: hist.BaseHist) -> svg: ey = -(e1 - e1[0]) / (e1[-1] - e1[0]) * height density = h.density() - max_dens = np.amax(density) or 1 + max_dens: float = np.amax(density) norm_vals: np.typing.NDArray[Any] = density / max_dens boxes = []