# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/06_issp.ipynb.

# %% auto 0
__all__ = ['sparr', 'spmtx', 'issparray', 'isspmatrix', 'issparr', 'isspmtx', 'issparse', 'isspr']

# %% ../nbs/06_issp.ipynb 4
from typing import TypeGuard, ForwardRef, TypeAlias, Union
try: from scipy.sparse import sparray, spmatrix
except ImportError: sparray, spmatrix = list, list
sparr: TypeAlias = ForwardRef('sp.sparse.sparray',  module='scipy.sparse', is_class=True)
spmtx: TypeAlias = ForwardRef('sp.sparse.spmatrix', module='scipy.sparse', is_class=True)

# %% ../nbs/06_issp.ipynb 6
def issparray(x) -> TypeGuard[sparr]:
    '''Check if `x` is an `sp.sparse.sparray`.
    
    See Also
    --------
    issparr : Alias for `issparray`.'''
    return isinstance(x, sparray)

def isspmatrix(x) -> TypeGuard[spmtx]:
    '''Check if `x` is an `sp.sparse.spmatrix`.
    
    See Also
    --------
    isspmtx : Alias for `isspmatrix`.
    '''
    return isinstance(x, spmatrix)

def issparr(x) -> TypeGuard[sparr]:
    '''Check if `x` is an `sp.sparse.sparray`.
    
    See Also
    --------
    issparray : Alias for `issparr`.
    '''
    return issparray(x)

def isspmtx(x) -> TypeGuard[spmtx]:
    '''Check if `x` is an `sp.sparse.spmatrix`.
    
    See Also
    --------
    isspmatrix : Alias for `isspmtx`.
    '''
    return isspmatrix(x)

def issparse(x) -> TypeGuard[Union[sparr, spmtx]]:
    '''Check if `x` is an `sp.sparse.sparray` or `sp.sparse.spmatrix`.
    
    See Also
    --------
    issparray : Alias for `issparr`.
    isspmatrix : Alias for `isspmtx`.
    '''
    return issparray(x) or isspmatrix(x)

def isspr(x) -> TypeGuard[Union[sparr, spmtx]]:
    '''Check if `x` is an `sp.sparse.sparray` or `sp.sparse.spmatrix`.
    
    See Also
    --------
    issparray : Alias for `issparr`.
    isspmatrix : Alias for `isspmtx`.
    issparse : Alias for `issparse`.
    '''
    return issparray(x) or isspmatrix(x)
