Open
Description
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 asTensor[T]
.
Originally posted by @kratsg in #2535 (comment)