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

fix: Add TYPE_CHECKING guard for numpy.typing #2208

Merged
merged 5 commits into from
May 18, 2023
Merged
Changes from 2 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
10 changes: 7 additions & 3 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
from __future__ import annotations

import logging
from typing import Callable, Generic, Mapping, Sequence, TypeVar, Union
from typing import TYPE_CHECKING, Callable, Generic, Mapping, Sequence, TypeVar, Union

import numpy as np
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray

# Needed while numpy lower bound is older than v1.21.0
if TYPE_CHECKING:
matthewfeickert marked this conversation as resolved.
Show resolved Hide resolved
from numpy.typing import ArrayLike, DTypeLike, NBitBase, NDArray

kratsg marked this conversation as resolved.
Show resolved Hide resolved
from scipy import special
from scipy.special import gammaln, xlogy
from scipy.stats import norm, poisson

from pyhf.typing import Literal, Shape

T = TypeVar("T", bound=NBitBase)
T = TypeVar("T", bound="NBitBase")

Tensor = Union["NDArray[np.number[T]]", "NDArray[np.bool_]"]
FloatIntOrBool = Literal["float", "int", "bool"]
Expand Down