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

# %% auto 0
__all__ = ['npbool', 'is01', 'isbooly']

# %% ../nbs/09_bool.ipynb 4
from typing import TypeGuard, Literal, Union, ForwardRef, TypeAlias

from .core import isbool

try: from numpy import bool_
except ImportError: bool_ = bool
npbool: TypeAlias = ForwardRef('np.bool_', module='numpy', is_class=True)

# %% ../nbs/09_bool.ipynb 6
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_)
