# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/61_ispd.ipynb.

# %% auto 0
__all__ = ['ispdna', 'notpdna', 'isdf', 'isidx', 'isseries', 'iscategoricalindex', 'iscatidx', 'iscidx', 'isboolindex',
           'isboolidx', 'isbidx', 'isindexlike', 'isidxlike']

# %% ../nbs/61_ispd.ipynb 4
from typing import TypeGuard
from typing import Any, Optional

# %% ../nbs/61_ispd.ipynb 5
from .atyp import (NA, DataFrame, Index, Series, CategoricalIndex)
from .atyp import (pdna, dataframe, pdindex, pdseries, pdcindex)
from .atyp import (BoolIndex, IndexLike, pdbindex, pdindexlike)

from .core import notnone

# %% ../nbs/61_ispd.ipynb 7
def ispdna(x) -> TypeGuard[pdna]:
    '''Check if `x` is `pd.NA`.'''
    return x is NA

def notpdna(x) -> TypeGuard[Any]:
    '''Check if `x` is not `pd.NA`.'''
    return not ispdna(x)

# %% ../nbs/61_ispd.ipynb 8
def isdf(x) -> TypeGuard[dataframe]:
    '''Check if `x` is an `pd.DataFrame`.'''
    return isinstance(x, DataFrame)

def isidx(x) -> TypeGuard[pdindex]:
    '''Check if `x` is an `pd.Index`.'''
    return isinstance(x, Index)

def isseries(x) -> TypeGuard[pdseries]:
    '''Check if `x` is an `pd.Series`.'''
    return isinstance(x, Series)

# %% ../nbs/61_ispd.ipynb 9
def iscategoricalindex(x) -> TypeGuard[pdcindex]:
    '''Check if `x` is an `pd.CategoricalIndex`.    
    
    See Also
    --------
    iscatidx : Alias for `iscategoricalindex`.
    iscidx : Alias for `iscategoricalindex`.
    '''
    return isinstance(x, CategoricalIndex)

def iscatidx(x) -> TypeGuard[pdcindex]:
    '''Check if `x` is an `pd.CategoricalIndex`.    
    
    See Also
    --------
    iscatidx : Alias for `iscatidx`.
    iscidx: Alias for `iscatidx`.
    '''
    return iscategoricalindex(x)

def iscidx(x) -> TypeGuard[pdcindex]:
    '''Check if `x` is an `pd.CategoricalIndex`.    
    
    See Also
    --------
    iscatidx : Alias for `iscidx`.
    iscategoricalindex: Alias for `iscidx`.
    '''
    return iscategoricalindex(x)


def isboolindex(x, r: Optional[pdindex] = None) -> TypeGuard[pdbindex]:
    '''Check if `x` is an `BoolIndex`. 

    Parameters
    ----------
    x : `Any`
        The object to check.

    r : `pd.Index`, default: None
        An optional reference index to check that `x` is the same length of.
    
    See Also
    --------
    isboolidx : Alias for `isboolindex`.
    isbidx : Alias for `isboolindex`.
    '''
    return isinstance(x, BoolIndex) and (len(x) == len(r) if notnone(r) else True)

def isboolidx(x, r: Optional[pdindex] = None) -> TypeGuard[pdbindex]:
    '''Check if `x` is an `BoolIndex`.    

    Parameters
    ----------
    x : `Any`
        The object to check.
        
    r : `pd.Index`, default: None
        An optional reference index to check that `x` is the same length of.
    
    See Also
    --------
    isboolindex : Alias for `isboolidx`.
    isbidx: Alias for `isboolidx`.
    '''
    return isboolindex(x, r)

def isbidx(x, r: Optional[pdindex] = None) -> TypeGuard[pdbindex]:
    '''Check if `x` is an `BoolIndex`.    
    Parameters
    ----------
    x : `Any`
        The object to check.
        
    r : `pd.Index`, default: None
        An optional reference index to check that `x` is the same length of.
    
    See Also
    --------
    isboolidx : Alias for `isbidx`.
    isboolindex: Alias for `isbidx`.
    '''
    return isboolindex(x, r)



def isindexlike(x) -> TypeGuard[pdindexlike]:
    '''Check if `x` is an `IndexLike`.    
    
    See Also
    --------
    isidxlike : Alias for `isindexlike`.
    '''
    return isinstance(x, IndexLike)

def isidxlike(x) -> TypeGuard[pdindexlike]:
    '''Check if `x` is an `IndexLike`.    
    
    See Also
    --------
    isindexlike : Alias for `isidxlike`.
    '''
    return isindexlike(x)
