Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions numpyro/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

from collections import OrderedDict
from collections.abc import Callable
from typing import Any, Optional, Protocol, Union, runtime_checkable
from typing import Any, Optional, Protocol, TypeVar, Union, runtime_checkable
import weakref

try:
from typing import ParamSpec, TypeAlias
except ImportError:
from typing_extensions import ParamSpec, TypeAlias


import numpy as np

import jax
Expand All @@ -36,6 +37,9 @@
"""A generic type for a pytree, i.e. a nested structure of lists, tuples, dicts, and arrays."""


NumLikeT = TypeVar("NumLikeT", bound=NumLike)


@runtime_checkable
class ConstraintT(Protocol):
"""A protocol for typing constraints."""
Expand All @@ -45,10 +49,10 @@ def is_discrete(self) -> bool: ...
@property
def event_dim(self) -> int: ...

def __call__(self, x: ArrayLike) -> ArrayLike: ...
def __call__(self, x: NumLike) -> ArrayLike: ...
def __repr__(self) -> str: ...
def check(self, value: ArrayLike) -> ArrayLike: ...
def feasible_like(self, prototype: ArrayLike) -> ArrayLike: ...
def check(self, value: NumLike) -> ArrayLike: ...
def feasible_like(self, prototype: NumLike) -> NumLike: ...


@runtime_checkable
Expand Down
Loading
Loading