# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_guard.ipynb.

# %% auto 0
__all__ = ['isnumstr', 'issignint', 'issignchr', 'issignsym', 'isexpochr', 'ispos', 'isneg', 'iszer']

# %% ../nbs/01_guard.ipynb 3
from numbers import Number
from typing import Any, TypeGuard

# %% ../nbs/01_guard.ipynb 4
from .types import NumStr, SignInt, SignChr, SignSym, ExpoChr

# %% ../nbs/01_guard.ipynb 5
from chck import isstr, isnum

# %% ../nbs/01_guard.ipynb 7
def isnumstr(v: Any) -> TypeGuard[NumStr]: 
    return isstr(v) or isnum(v)

def issignint(v: Any) -> TypeGuard[SignInt]: return v in {1, 0, -1}       # isinstance(v, SignInt)
def issignchr(v: Any) -> TypeGuard[SignChr]: return v in {'P', 'N', ''}   # isinstance(v, SignChr)
def issignsym(v: Any) -> TypeGuard[SignSym]: return v in {'+', '-', ''}   # isinstance(v, SignSym)
def isexpochr(v: Any) -> TypeGuard[ExpoChr]: return v in {'^', '**', 'E'} # isinstance(v, ExpoChr)

def ispos(n: Number) -> bool: return isnum(n) and n > 0
def isneg(n: Number) -> bool: return isnum(n) and n < 0
def iszer(n: Number) -> bool: return isnum(n) and n == 0
