# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/14_bool.ipynb.

# %% auto 0
__all__ = ['is01', 'isbooly', 'isbooltype', 'isbtype', 'isboolcall', 'isbcall']

# %% ../nbs/14_bool.ipynb 4
from typing import TypeGuard
from typing import Type, Callable, Literal, Union

# %% ../nbs/14_bool.ipynb 5
from .atyp import bool_, npbool
from .core import isbool, iscall

# %% ../nbs/14_bool.ipynb 7
def is01(x) -> TypeGuard[Union[Literal[0], Literal[1]]]: 
    '''Check if `x` is either `0` or `1`.'''
    return x in [0, 1]

def isbooly(x) -> TypeGuard[Union[bool, npbool, Literal[0], Literal[1]]]:
    '''Check if `x` is one of `bool`, `np.bool_`, `0`, or `1`.'''
    return isbool(x) or is01(x) or isinstance(x, bool_)


def isbooltype(x) -> TypeGuard[Type[bool]]:
    '''Check if `x` is the `bool` type.
    
    See Also
    --------
    isbtype : Alias for `isbooltype`.
    '''
    return x == bool

def isbtype(x) -> TypeGuard[Type[bool]]:
    '''Check if `x` is the `bool` type.
    
    See Also
    --------
    isbooltype : Alias for `isbtype`.
    '''
    return isbooltype(x)

def isboolcall(x) -> TypeGuard[Union[bool, npbool, Literal[0], Literal[1], Callable]]:
    '''Check if `x` is one of `bool`, `np.bool_`, `0`, `1`, or `Callable`.
    
    See Also
    --------
    isbcall : Alias for `isboolcall`.
    '''
    return isbool(x) or iscall(x) or is01(x) or isinstance(x, bool_)

def isbcall(x):
    '''Check if `x` is one of `bool`, `np.bool_`, `0`, `1`, or `Callable`.
    
    See Also
    --------
    isboolcall : Alias for `isbcall`.
    '''
    return isboolcall(x)
