How to use the symengine.lib.symengine_wrapper.Basic function in symengine

To help you get started, we’ve selected a few symengine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github symengine / symengine.py / symengine / utilities.py View on Github external
def traverse(symbols, frame):
        """Recursively inject symbols to the global namespace. """
        for symbol in symbols:
            if isinstance(symbol, Basic):
                frame.f_globals[symbol.__str__()] = symbol
            # Once we hace an undefined function class
            # implemented, put a check for function here
            else:
                traverse(symbol, frame)
github symengine / symengine.py / symengine / utilities.py View on Github external
for symbol in symbols:
            if isinstance(symbol, Basic):
                frame.f_globals[symbol.__str__()] = symbol
            # Once we hace an undefined function class
            # implemented, put a check for function here
            else:
                traverse(symbol, frame)

    from inspect import currentframe
    frame = currentframe().f_back

    try:
        syms = symbols(names, **args)

        if syms is not None:
            if isinstance(syms, Basic):
                frame.f_globals[syms.__str__()] = syms
            # Once we hace an undefined function class
            # implemented, put a check for function here
            else:
                traverse(syms, frame)
    finally:
        del frame  # break cyclic dependencies as stated in inspect docs

    return syms
github symengine / symengine.py / symengine / printing.py View on Github external
def doprint(self, expr, assign_to=None):
        if not isinstance(assign_to, (Basic, type(None), str)):
            raise TypeError("{0} cannot assign to object of type {1}".format(
                    type(self).__name__, type(assign_to)))

        expr = sympify(expr)
        if not assign_to:
            if expr.is_Matrix:
                raise RuntimeError("Matrices need a assign_to parameter")
            return ccode(expr)

        assign_to = str(assign_to)
        if not expr.is_Matrix:
            return "{} = {};".format(assign_to, ccode(expr))

        code_lines = []
        for i, element in enumerate(expr):
            code_line = '{}[{}] = {};'.format(assign_to, i, element)