Skip to content

type annotation NdarrayOrTensor #2823

Description

@wyli

Is your feature request related to a problem? Please describe.
NdarrayOrTensor should be replaced by a type variable such as NdarrayTensor
this will ensure advanced type checks for correctness however it might not be supported by all the tools such as pytype, mypy

Additional context

NdarrayTensor = TypeVar("NdarrayTensor", np.ndarray, torch.Tensor)
"""NdarrayTensor
Generic type which can represent either a numpy.ndarray or a torch.Tensor
Unlike Union can create a dependence between parameter(s) / return(s)
"""
NdarrayOrTensor = Union[np.ndarray, torch.Tensor]
"""NdarrayOrTensor
Union of numpy.ndarray and torch.Tensor to be used for typing
"""

this is a follow up of #2815

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions