# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/09_named_dims.ipynb.

# %% auto 0
__all__ = ['NamedDimsMeta', 'NamedDims']

# %% ../nbs/09_named_dims.ipynb 4
from typing import Any, Dict, Tuple

# %% ../nbs/09_named_dims.ipynb 5
from .pttype import PTMeta, PTType

# %% ../nbs/09_named_dims.ipynb 7
class NamedDimsMeta(PTMeta):
    """
    Metaclass for NamedDims. It contains logic for instance checking.
    """

    __args__: Tuple[Dict[str, int]]
    _parameterized: bool

    def __getitem__(cls, item):
        if not isinstance(item, dict):
            raise TypeError("NamedDims expects a dictionary argument.")
        return super().__getitem__(item)

    def __str__(cls):
        named_dims = cls.__args__[0]
        return f"NamedDims[{named_dims}]"
    
    # def __instancecheck__(cls, instance):
    #     named_dims = cls.__args__[0]

    #     # Check dimensions
    #     if named_dims is not Any and instance.shape != tuple(named_dims.values()):
    #         return False

    #     return True

# %% ../nbs/09_named_dims.ipynb 8
class NamedDims(PTType, metaclass=NamedDimsMeta):
    """
    Represents named dimensions in a tensor.
    """

    __args__ = (Any,)
