Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [pre-commit.ci] pre-commit autoupdate #2535

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

@matthewfeickert matthewfeickert self-assigned this Aug 5, 2024
@matthewfeickert matthewfeickert added chore Other changes that don't modify src or test files need-to-backport tmp label until can be backported to patch release branch labels Aug 5, 2024
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.21%. Comparing base (aab3468) to head (1f451bd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2535   +/-   ##
=======================================
  Coverage   98.21%   98.21%           
=======================================
  Files          69       69           
  Lines        4543     4543           
  Branches      804      804           
=======================================
  Hits         4462     4462           
  Misses         48       48           
  Partials       33       33           
Flag Coverage Δ
contrib 97.79% <ø> (ø)
doctest 98.08% <ø> (ø)
unittests-3.10 96.23% <ø> (ø)
unittests-3.11 96.23% <ø> (ø)
unittests-3.12 96.23% <ø> (ø)
unittests-3.8 96.25% <ø> (ø)
unittests-3.9 96.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit is failing on mypy now with

mypy with Python 3.8.....................................................Failed
- hook id: mypy
- exit code: 1

src/pyhf/tensor/numpy_backend.py:38: error: Argument 2 to "poisson_logpdf" of "numpy_backend" has incompatible type "Union[ndarray[Any, dtype[number[T@__init__]]], ndarray[Any, dtype[bool]]]"; expected "Union[ndarray[Any, dtype[number[T@log_prob]]], ndarray[Any, dtype[bool]]]"  [arg-type]
src/pyhf/tensor/numpy_backend.py:51: error: Argument 2 to "normal_logpdf" of "numpy_backend" has incompatible type "Union[ndarray[Any, dtype[number[T@__init__]]], ndarray[Any, dtype[bool]]]"; expected "Union[ndarray[Any, dtype[number[T@log_prob]]], ndarray[Any, dtype[bool]]]"  [arg-type]
src/pyhf/tensor/numpy_backend.py:51: error: Argument 3 to "normal_logpdf" of "numpy_backend" has incompatible type "Union[ndarray[Any, dtype[number[T@__init__]]], ndarray[Any, dtype[bool]]]"; expected "Union[ndarray[Any, dtype[number[T@log_prob]]], ndarray[Any, dtype[bool]]]"  [arg-type]
Found 3 errors in 1 file (checked 72 source files)

mypy with Python 3.12....................................................Failed
- hook id: mypy
- exit code: 1

src/pyhf/tensor/numpy_backend.py:38: error: Argument 2 to "poisson_logpdf" of "numpy_backend" has incompatible type "ndarray[Any, dtype[number[T@__init__]]] | ndarray[Any, dtype[bool]]"; expected "ndarray[Any, dtype[number[T@log_prob]]] | ndarray[Any, dtype[bool]]"  [arg-type]
src/pyhf/tensor/numpy_backend.py:51: error: Argument 2 to "normal_logpdf" of "numpy_backend" has incompatible type "ndarray[Any, dtype[number[T@__init__]]] | ndarray[Any, dtype[bool]]"; expected "ndarray[Any, dtype[number[T@log_prob]]] | ndarray[Any, dtype[bool]]"  [arg-type]
src/pyhf/tensor/numpy_backend.py:51: error: Argument 3 to "normal_logpdf" of "numpy_backend" has incompatible type "ndarray[Any, dtype[number[T@__init__]]] | ndarray[Any, dtype[bool]]"; expected "ndarray[Any, dtype[number[T@log_prob]]] | ndarray[Any, dtype[bool]]"  [arg-type]
Found 3 errors in 1 file (checked 72 source files)

@kratsg
Copy link
Contributor

kratsg commented Aug 6, 2024

Looks like there's a slightly different type coercion needed here (taking one as an example0

src/pyhf/tensor/numpy_backend.py:38: error: Argument 2 to "poisson_logpdf" of "numpy_backend" has incompatible type

got:
"Union[ndarray[Any, dtype[number[T@__init__]]], ndarray[Any, dtype[bool]]]"

expected:
"Union[ndarray[Any, dtype[number[T@log_prob]]], ndarray[Any, dtype[bool]]]"

so need to dig into why. The @ notation is throwing me off a little (must be related to the generics). /cc @henryiii or @alexander-held if they've seen this before.

with this code

class _BasicPoisson:
    def __init__(self, rate: Tensor[T]):
        self.rate = rate

    def sample(self, sample_shape: Shape) -> ArrayLike:
        return poisson(self.rate).rvs(size=sample_shape + self.rate.shape)  # type: ignore[no-any-return]

    def log_prob(self, value: NDArray[np.number[T]]) -> ArrayLike:
        tensorlib: numpy_backend[T] = numpy_backend()
        return tensorlib.poisson_logpdf(value, self.rate)

here, it seems to complain about self.rate which is typed as Tensor[T].

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.6.3](astral-sh/ruff-pre-commit@v0.5.0...v0.6.3)
- [github.com/psf/black-pre-commit-mirror: 24.4.2 → 24.8.0](psf/black-pre-commit-mirror@24.4.2...24.8.0)
- [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.2](pre-commit/mirrors-mypy@v1.10.1...v1.11.2)
- [github.com/python-jsonschema/check-jsonschema: 0.28.6 → 0.29.2](python-jsonschema/check-jsonschema@0.28.6...0.29.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Other changes that don't modify src or test files need-to-backport tmp label until can be backported to patch release branch
Projects
Status: Review in progress
Development

Successfully merging this pull request may close these issues.

2 participants