Symbol decorator.
181801
def method(self, symbol):
        '''
        
        '''
        assert issubclass(symbol, SymbolBase)
        def wrapped(fn):
            setattr(symbol, fn.__name__, fn)
        return wrapped
164041
def _symbol_in(self, symbol, name):
        """"""
        lsymbol = symbol.lower()
        lname = name.lower()
        return lsymbol == lname[:len(symbol)] or "_" + lsymbol in lname
1159387
def _translate_symbols(string):
    """"""
    res = []
    string = str(string)
    for s in re.split(r'(\W+)', string, flags=re.UNICODE):
        tex_str = _GREEK_DICTIONARY.get(s)
        if tex_str:
            res.append(tex_str)
        elif s.lower() in _GREEK_DICTIONARY:
            res.append(_GREEK_DICTIONARY[s])
        else:
            res.append(s)
    return "".join(res)
1249343
def _operator_symbol_handler(c, ctx):
    """"""
    assert c in _OPERATORS
    ctx.set_unicode()
    val = ctx.value
    val.append(c)
    c, self = yield
    trans = ctx.immediate_transition(self)
    while c in _OPERATORS:
        val.append(c)
        c, _ = yield trans
    yield ctx.event_transition(IonEvent, IonEventType.SCALAR, IonType.SYMBOL, val.as_symbol())
510968
def zsymDecorator(odd):
    """"""
    def wrapper(func):
        @wraps(func)
        def zsym_wrapper(*args,**kwargs):
            if args[0]._zsym:
                out= func(args[0],args[1],numpy.fabs(args[2]),**kwargs)
            else:
                out= func(*args,**kwargs)
            if odd and args[0]._zsym:
                return sign(args[2])*out
            else:
                return out
        return zsym_wrapper
    return wrapper
58744
def use_google_symbol(fct):
    '''
    
    '''
    def decorator(symbols):
        google_symbols = []

        # If one symbol string
        if isinstance(symbols, str):
            symbols = [symbols]

        symbols = sorted(symbols)
        for symbol in symbols:
            dot_pos = symbol.find('.')
            google_symbols.append(
                symbol[:dot_pos] if (dot_pos > 0) else symbol)

        data = fct(google_symbols)
        #NOTE Not very elegant
        data.columns = [s for s in symbols if s.split('.')[0] in data.columns]
        return data
    return decorator
909505
def wrap(sig):
    """"""
    if isclass(sig) and issubclass(sig, Object):
      return TypeSignature(sig)
    elif isinstance(sig, TypeSignature):
      return sig
821854
def decorator(cls, func_or_class):
        """"""
        resources = getattr(func_or_class, 'resources', [])
        resources.append(cls)
        func_or_class.resources = resources
        return func_or_class
91771
def decorate_function(self, name, decorator):
        
        self.functions[name] = decorator(self.functions[name])
740601
def symbolize(flt: float) -> sympy.Symbol:
    
    try:
        ratio = rationalize(flt)
        res = sympy.simplify(ratio)
    except ValueError:
        ratio = rationalize(flt/np.pi)
        res = sympy.simplify(ratio) * sympy.pi
    return res
33559
def visit_decorators(self, node):
        """"""
        return "@%s\n" % "\n@".join(item.accept(self) for item in node.nodes)
1066005
def decorator_info(f_name, expected, actual, flag):
    
    format = lambda types: ', '.join([str(t).split("'")[1] for t in types])
    expected, actual = format(expected), format(actual)
    msg = "'{}' method ".format(f_name) \
          + ("accepts", "returns")[flag] + " ({}), but ".format(expected) \
          + ("was given", "result is")[flag] + " ({})".format(actual)

    return msg
576370
def prepare_function_symbol(self, symbol_name, basic_addr=None):
        
        if basic_addr is None:
            basic_addr = self.project.loader.extern_object.get_pseudo_addr(symbol_name)
        return basic_addr, basic_addr
446636
def wraps(__fn, **kw):
        """"""
        kw['assigned'] = kw.get('assigned', WRAPPER_ASSIGNMENTS)
        return functools.wraps(__fn, **kw)
305637
function addSymbol (s) {
        if (s && !symbols_[s]) {
            symbols_[s] = ++symbolId;
            symbols.push(s);
        }
    }
799603
def optional_argument_decorator(_decorator):
    """"""

    @functools.wraps(_decorator)
    def inner_decorator_make(*args, **kwargs):
        if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
            func = args[0]
            args = tuple()
            kwargs = dict()
        else:
            func = None

        decorator = _decorator(*args, **kwargs)

        if func:
            return decorator(func)
        else:
            return decorator

    return inner_decorator_make
189781
def scalarDecorator(func):
    """"""
    @wraps(func)
    def scalar_wrapper(*args,**kwargs):
        if nu.array(args[0]).shape == ():
            scalarOut= True
            newargs= ()
            for ii in range(len(args)):
                newargs= newargs+(nu.array([args[ii]]),)
            args= newargs
        else:
            scalarOut= False
        result= func(*args,**kwargs)
        if scalarOut:
            out= ()
            for ii in range(result.shape[1]):
                out= out+(result[0,ii],)
            return out
        else:
            return result
    return scalar_wrapper