Skip to content

Commit

Permalink
Typing, linting, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondEhlers committed Dec 13, 2024
1 parent 36f89bf commit 0e35a11
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classifiers = [
dynamic = ["version"]
dependencies = [
"attrs >=21.2.0",
"numpy >=1.21",
"numpy >=2.0",
"scipy >=1.7.0",
"matplotlib >=3.3.2",
"iminuit >=2.7.0",
Expand All @@ -56,8 +56,8 @@ dev = [
"pytest-xdist >=3.5.0",
"pytest-sugar >=1.0.0",
"uproot >=4",
"boost-histogram >=1.2.1",
"hist >=2.7.1",
"boost-histogram >=1.5",
"hist >=2.8",
]
docs = [
"sphinx>=7.0",
Expand Down
8 changes: 4 additions & 4 deletions src/pachyderm/binned_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def _apply_rebin(

# Only use numba if available
f = _sum_values_for_rebin_numba if _sum_values_for_rebin_numba is not None else _sum_values_for_rebin
return f( # type: ignore[no-any-return]
return f(
n_bins_new_axis=n_bins_new_axis,
values=values,
run_starts=run_starts,
Expand All @@ -1264,9 +1264,9 @@ def _apply_rebin(
def _sum_values_for_rebin(
n_bins_new_axis: int,
values: npt.NDArray[np.float64],
run_starts: npt.NDArray[np.float64],
run_values: npt.NDArray[np.float64],
run_lengths: npt.NDArray[np.float64],
run_starts: npt.NDArray[np.int64],
run_values: npt.NDArray[np.int64],
run_lengths: npt.NDArray[np.int64],
) -> npt.NDArray[np.float64]:
"""Implementation of summing up values for the rebinning
Expand Down
2 changes: 1 addition & 1 deletion src/pachyderm/fit/cost_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(self, *cost_functions: T_CostFunction | SimultaneousFit):

def __add__(self, other: T_CostFunction | SimultaneousFit) -> SimultaneousFit:
"""Add a new function to the simultaneous fit."""
return type(self)(self, other)
return type(self)(self, other) # type: ignore[arg-type]

def __radd__(self, other: T_CostFunction | SimultaneousFit) -> SimultaneousFit:
"""For use with ``sum(...)``."""
Expand Down
4 changes: 2 additions & 2 deletions src/pachyderm/generic_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ def iterate_with_selected_objects_in_order(
selected_analysis_objects = []
for selected_values in itertools.product(*selected_iterators):
for key_index, obj in analysis_objects.items():
selected_via_analysis_iterables = all(getattr(key_index, k) == v for k, v in values)
selected_via_selected_iterators = all(getattr(key_index, k) == v for k, v in selected_values)
selected_via_analysis_iterables = all(getattr(key_index, k) == v for k, v in values) # type: ignore[misc,has-type]
selected_via_selected_iterators = all(getattr(key_index, k) == v for k, v in selected_values) # type: ignore[misc,has-type]
selected_obj = selected_via_analysis_iterables and selected_via_selected_iterators

if selected_obj:
Expand Down
2 changes: 1 addition & 1 deletion src/pachyderm/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def _integral(
# Provide the opportunity to scale by bin width
widths = np.ones(len(self.y))
if multiply_by_bin_width:
widths = self.bin_widths
widths = self.bin_widths # type: ignore[assignment]

# Integrate by summing up all of the bins and the errors.
# Perform the integral.
Expand Down
2 changes: 1 addition & 1 deletion tests/fit/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def test_gaussian() -> None:
"""Test the gaussian function."""
# Setup
x = np.arange(-10, 10, 0.1)
x = np.arange(-10, 10, 0.1, dtype=np.float64)
mean = 0.5
sigma = 4.2

Expand Down
6 changes: 5 additions & 1 deletion tests/test_binned_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import annotations

import logging
from typing import Any

import numpy as np
Expand All @@ -12,6 +13,8 @@

from pachyderm import binned_data

logger = logging.getLogger(__name__)


def test_axis_slice_copy() -> None:
axis = binned_data.Axis(np.arange(1, 11))
Expand Down Expand Up @@ -65,6 +68,7 @@ def test_axis_slice(
hist = pytest.importorskip("hist")
hist_s = slice(s.start, s.stop, hist.rebin(s.step) if s.step else s.step)
hist_h = hist.Hist(hist.axis.Regular(10, 1, 11))
logger.info(f"{hist_h.axes[0].edges}")
hist_sliced_axis = hist_h[hist_s].axes[0]

np.testing.assert_allclose(sliced_axis.bin_edges, hist_sliced_axis.edges)
Expand Down Expand Up @@ -103,7 +107,7 @@ def test_axis_slice_rebin(
np.testing.assert_allclose(sliced_axis.bin_edges, expected_bin_edges)


@pytest.fixture()
@pytest.fixture
def hists_for_rebinning() -> tuple[npt.NDArray[np.float64], binned_data.BinnedData]:
_values = []
for i in range(2, 12):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)


@pytest.fixture()
@pytest.fixture
def retrieve_root_list(test_root_hists: Any) -> Iterator[tuple[str, Any, Any]]:
"""Create an set of lists to load for a ROOT file.
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_retrieve_object(self, retrieve_root_list: Any) -> None:
assert output == expected


@pytest.fixture()
@pytest.fixture
def setup_histogram_conversion() -> tuple[str, str, histogram.Histogram1D]:
"""Setup expected values for histogram conversion tests.
Expand Down Expand Up @@ -569,7 +569,7 @@ def test_get_array_from_hist2D(self, use_bin_edges, set_zero_to_NaN, test_root_h
assert np.isclose(hist_array[0][1], 0.0)


@pytest.fixture()
@pytest.fixture
def setup_basic_hist() -> (
tuple[histogram.Histogram1D, npt.NDArray[np.float64], npt.NDArray[np.float64], npt.NDArray[np.float64]]
):
Expand Down

0 comments on commit 0e35a11

Please sign in to comment.