pandera.api.tensordict.components.TensorΒΆ
- class pandera.api.tensordict.components.Tensor(dtype=None, shape=None, checks=None, nullable=False, coerce=False, name=None, required=True)[source]ΒΆ
Validate a single tensor entry in a TensorDict.
Analogous to
Columnfor DataFrames andDataVarfor xarray Datasets.Create tensor validator.
- Parameters:
dtype (
Any) β PyTorch dtype (e.g.,torch.float32,torch.int64). If a string is provided, it will be converted to the corresponding torch.dtype.shape (
UnionType[tuple[UnionType[int,None], β¦],None]) β Expected shape tuple. UseNonefor flexible dimensions. For example,(None, 10)allows any batch size with 10 features.checks (
Union[Check,list[Union[Check,Hypothesis]],None]) β List ofCheckinstances for value validation.nullable (
bool) β Whether the key can be missing from the TensorDict.coerce (
bool) β Whether to coerce dtype during validation.name (
Union[str,tuple[str, β¦],None]) β Tensor key name in TensorDict. IfNone, uses the key from the schema definition. May be a nested tuple key.required (
bool) β Whether the tensor is required (alwaysTruefor now, as missing keys are handled separately).
Methods
- __init__(dtype=None, shape=None, checks=None, nullable=False, coerce=False, name=None, required=True)[source]ΒΆ
Create tensor validator.
- Parameters:
dtype (
Any) β PyTorch dtype (e.g.,torch.float32,torch.int64). If a string is provided, it will be converted to the corresponding torch.dtype.shape (
UnionType[tuple[UnionType[int,None], β¦],None]) β Expected shape tuple. UseNonefor flexible dimensions. For example,(None, 10)allows any batch size with 10 features.checks (
Union[Check,list[Union[Check,Hypothesis]],None]) β List ofCheckinstances for value validation.nullable (
bool) β Whether the key can be missing from the TensorDict.coerce (
bool) β Whether to coerce dtype during validation.name (
Union[str,tuple[str, β¦],None]) β Tensor key name in TensorDict. IfNone, uses the key from the schema definition. May be a nested tuple key.required (
bool) β Whether the tensor is required (alwaysTruefor now, as missing keys are handled separately).