Did I find the right examples for you? yes no

All Samples(12)  |  Call(9)  |  Derive(0)  |  Import(3)
return pretty representation of a symbol

        def pretty_symbol(symb_name):
    """return pretty representation of a symbol"""
    # let's split symb_name into symbol + index
    # UC: beta1
    # UC: f_beta

    if not _use_unicode:
        return symb_name

    name, sups, subs = split_super_sub(symb_name)

    def translate(s) :
        gG = greek_unicode.get(s)
        if gG is not None:
            return gG
        for key in sorted(modifier_dict.keys(), key=lambda k:len(k), reverse=True) :
            if s.lower().endswith(key) and len(s)>len(key):
                return modifier_dict[key](translate(s[:-len(key)]))
        return s

    name = translate(name)

    # Let's prettify sups/subs. If it fails at one of them, pretty sups/subs are
    # not used at all.
    def pretty_list(l, mapping):
        result = []
        for s in l:
            pretty = mapping.get(s)
            if pretty is None:
                try:  # match by separate characters
                    pretty = ''.join([mapping[c] for c in s])
                except KeyError:
                    return None
            result.append(pretty)
        return result

    pretty_sups = pretty_list(sups, sup)
    if pretty_sups is not None:
        pretty_subs = pretty_list(subs, sub)
    else:
        pretty_subs = None

    # glue the results into one string
    if pretty_subs is None:  # nice formatting of sups/subs did not work
        if subs:
            name += '_'+'_'.join([translate(s) for s in subs])
        if sups:
            name += '__'+'__'.join([translate(s) for s in sups])
        return name
    else:
        sups_result = ' '.join(pretty_sups)
        subs_result = ' '.join(pretty_subs)

    return ''.join([name, sups_result, subs_result])
        


src/s/y/sympy-0.7.5/sympy/printing/pretty/pretty.py   sympy(Download)
 
from .stringpict import prettyForm, stringPict
from .pretty_symbology import xstr, hobj, vobj, xobj, xsym, pretty_symbol, \
    pretty_atom, pretty_use_unicode, pretty_try_use_unicode, greek_unicode, U, \
    annotated
    def _print_Symbol(self, e):
        symb = pretty_symbol(e.name)
        return prettyForm(symb)
    _print_RandomSymbol = _print_Symbol
 
            form = 'GF(%d)'
 
        return prettyForm(pretty_symbol(form % expr.mod))
 
    def _print_IntegerRing(self, expr):
        pform = prettyForm(*pform.right((self._print(e.args[1]))))
        if self._use_unicode:
            a = stringPict(pretty_symbol('delta'))
        else:
            a = stringPict('d')
        # All components of the morphism have names and it is thus
        # possible to build the name of the composite.
        component_names_list = [pretty_symbol(component.name) for
                                component in morphism.components]
        component_names_list.reverse()

src/s/y/sympy-HEAD/sympy/printing/pretty/pretty.py   sympy(Download)
 
from .stringpict import prettyForm, stringPict
from .pretty_symbology import xstr, hobj, vobj, xobj, xsym, pretty_symbol, \
    pretty_atom, pretty_use_unicode, pretty_try_use_unicode, greek_unicode, U, \
    annotated
    def _print_Symbol(self, e):
        symb = pretty_symbol(e.name)
        return prettyForm(symb)
    _print_RandomSymbol = _print_Symbol
 
            form = 'GF(%d)'
 
        return prettyForm(pretty_symbol(form % expr.mod))
 
    def _print_IntegerRing(self, expr):
        pform = prettyForm(*pform.right((self._print(e.args[1]))))
        if self._use_unicode:
            a = stringPict(pretty_symbol('delta'))
        else:
            a = stringPict('d')
        # All components of the morphism have names and it is thus
        # possible to build the name of the composite.
        component_names_list = [pretty_symbol(component.name) for
                                component in morphism.components]
        component_names_list.reverse()

src/s/y/sympy-polys-HEAD/sympy/printing/pretty/pretty.py   sympy-polys(Download)
from sympy import Interval
 
from pretty_symbology import xstr, hobj, vobj, xobj, xsym, pretty_symbol,\
        pretty_atom, pretty_use_unicode, pretty_try_use_unicode, greek
 
    def _print_Symbol(self, e):
        symb = pretty_symbol(e.name)
        return prettyForm(symb)
 
    def _print_Real(self, e):