abracudabra._validate ===================== .. py:module:: abracudabra._validate Attributes ---------- .. autoapisummary:: abracudabra._validate.LIBRARY_TO_CONCRETE_TYPES Classes ------- .. autoapisummary:: abracudabra._validate.Library Functions --------- .. autoapisummary:: abracudabra._validate._get_numpy_type abracudabra._validate._get_cupy_type abracudabra._validate._get_torch_type abracudabra._validate._get_pandas_type abracudabra._validate._get_cudf_type abracudabra._validate._get_concrete_types abracudabra._validate.validate_obj_type Module Contents --------------- .. py:function:: _get_numpy_type() -> dict[str, type] .. py:function:: _get_cupy_type() -> dict[str, type] .. py:function:: _get_torch_type() -> dict[str, type] .. py:function:: _get_pandas_type() -> dict[str, type] .. py:function:: _get_cudf_type() -> dict[str, type] .. py:class:: Library(*args, **kwds) Bases: :py:obj:`enum.Enum` Library names. .. py:attribute:: numpy :value: 'numpy' .. py:attribute:: cupy :value: 'cupy' .. py:attribute:: torch :value: 'torch' .. py:attribute:: pandas :value: 'pandas' .. py:attribute:: cudf :value: 'cudf' .. py:data:: LIBRARY_TO_CONCRETE_TYPES :type: dict[Library, collections.abc.Callable[[], collections.abc.Mapping[str, type]]] Mapping from library names to functions that return a mapping of concrete types. .. py:function:: _get_concrete_types(library: Library, types: str | collections.abc.Iterable[str] | None = None) -> type | tuple[type, Ellipsis] .. py:function:: validate_obj_type(obj: object, /, library: Literal[Library], types: str | collections.abc.Iterable[str] | None = ...) -> TypeGuard[numpy.ndarray] validate_obj_type(obj: object, /, library: Literal[Library], types: str | collections.abc.Iterable[str] | None = ...) -> TypeGuard[Any] validate_obj_type(obj: object, /, library: Literal[Library], types: str | collections.abc.Iterable[str] | None = ...) -> TypeGuard[torch.Tensor] validate_obj_type(obj: object, /, library: Literal[Library], types: str | collections.abc.Iterable[str] | None = ...) -> TypeGuard[pandas.Index | pandas.Series[Any] | pandas.DataFrame] validate_obj_type(obj: object, /, library: Literal[Library], types: str | collections.abc.Iterable[str] | None = ...) -> TypeGuard[cudf.Index | cudf.Series | cudf.DataFrame] validate_obj_type(obj: object, /, library: Library, types: str | collections.abc.Iterable[str] | None = ...) -> bool Validate an object ensuring it matches the type from a specified library. :param obj: The object to validate. :param library: Library name from Enum 'Library'. :param types: The type(s) to validate against. For example, ``'array'``, ``'index'``, ``'series'``, ``'dataframe'``, ``'tensor'``. :returns: The input object, if validation succeeds. :raises ValueError: If an unsupported library is provided. :raises TypeError: If the object type doesn't match the expected type.