当前位置: 首页>>代码示例>>Python>>正文


Python printing.init_printing函数代码示例

本文整理汇总了Python中sympy.interactive.printing.init_printing函数的典型用法代码示例。如果您正苦于以下问题:Python init_printing函数的具体用法?Python init_printing怎么用?Python init_printing使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了init_printing函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_session

def init_session(ipython=None, pretty_print=True, order=None,
        use_unicode=None, quiet=False, argv=[]):
    """Initialize an embedded IPython or Python session. """
    import sys

    in_ipython = False

    if ipython is False:
        ip = _init_python_session()
        mainloop = ip.interact
    else:
        try:
            import IPython
        except ImportError:
            if ipython is not True:
                if not quiet:
                    print no_ipython
                ip = _init_python_session()
                mainloop = ip.interact
            else:
                raise RuntimeError("IPython is not available on this system")
        else:
            ipython = True
            if IPython.__version__ >= '0.11':
                try:
                    ip = get_ipython()
                except NameError:
                    ip = None
            else:
                ip = IPython.ipapi.get()
                if ip:
                    ip = ip.IP

            if ip is not None:
                in_ipython = True
            else:
                ip = _init_ipython_session(argv)

            if IPython.__version__ >= '0.11':
                # runsource is gone, use run_cell instead, which doesn't
                # take a symbol arg.  The second arg is `store_history`,
                # and False means don't add the line to IPython's history.
                ip.runsource = lambda src, symbol='exec': ip.run_cell(src, False)
                mainloop = ip.mainloop
            else:
                mainloop = ip.interact

    _preexec_source = preexec_source

    ip.runsource(_preexec_source, symbol='exec')
    init_printing(pretty_print=pretty_print, order=order, use_unicode=use_unicode, ip=ip)

    message = _make_message(ipython, quiet, _preexec_source)

    if not in_ipython:
        mainloop(message)
        sys.exit('Exiting ...')
    else:
        ip.write(message)
        ip.set_hook('shutdown_hook', lambda ip: ip.write("Exiting ...\n"))
开发者ID:ArchKaine,项目名称:sympy,代码行数:60,代码来源:session.py

示例2: load_ipython_extension

def load_ipython_extension(ip):
    """Load the extension in IPython."""
    # Since Python filters deprecation warnings by default,
    # we add a filter to make sure this message will be shown.
    warnings.simplefilter("once", SymPyDeprecationWarning)
    SymPyDeprecationWarning(
        feature="using %load_ext sympy.interactive.ipythonprinting",
        useinstead="from sympy import init_printing ; init_printing()",
        deprecated_since_version="0.7.3",
        issue=3914
    ).warn()
    init_printing(ip=ip)
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:12,代码来源:ipythonprinting.py

示例3: load_ipython_extension

def load_ipython_extension(ip):
    """Load the extension in IPython."""
    import IPython

    global _loaded
    # Use extension manager to track loaded status if available
    # This is currently in IPython 0.14.dev
    if hasattr(ip.extension_manager, 'loaded'):
        loaded = 'sympy.interactive.ipythonprinting' not in ip.extension_manager.loaded
    else:
        loaded = _loaded

    if not loaded:
        init_printing(ip=ip)
        _loaded = True
开发者ID:dyao-vu,项目名称:meta-core,代码行数:15,代码来源:ipythonprinting.py

示例4: init_session

def init_session(ipython=None, pretty_print=True, order=None,
        use_unicode=None, quiet=False, keep_sign=False, argv=[]):
    """Initialize an embedded IPython or Python session. """
    import sys

    in_ipython = False

    if ipython is False:
        ip = _init_python_session()
    else:
        try:
            import IPython
        except ImportError:
            if ipython is not True:
                print no_ipython
                ip = _init_python_session()
            else:
                raise RuntimeError("IPython is not available on this system")
        else:
            ip = IPython.ipapi.get()
            ipython = True

            if ip is not None:
                ip, in_ipython = ip.IP, True
            else:
                ip = _init_ipython_session(argv)

    _preexec_source = preexec_source

    if keep_sign:
        _preexec_source += "Basic.keep_sign = True\n"

    ip.runsource(_preexec_source, symbol='exec')
    init_printing(pretty_print=pretty_print, order=order, use_unicode=use_unicode)

    message = _make_message(ipython, quiet, _preexec_source)

    if not in_ipython:
        ip.interact(message)
        sys.exit('Exiting ...')
    else:
        ip.write(message)
        ip.set_hook('shutdown_hook', lambda ip: ip.write("Exiting ...\n"))
开发者ID:haz,项目名称:sympy,代码行数:43,代码来源:session.py

示例5: init_vprinting

def init_vprinting(**kwargs):
    """Initializes time derivative printing for all SymPy objects, i.e. any
    functions of time will be displayed in a more compact notation. The main
    benefit of this is for printing of time derivatives; instead of
    displaying as ``Derivative(f(t),t)``, it will display ``f'``. This is
    only actually needed for when derivatives are present and are not in a
    physics.vector.Vector or physics.vector.Dyadic object. This function is a
    light wrapper to `sympy.interactive.init_printing`. Any keyword
    arguments for it are valid here.

    {0}

    Examples
    ========

    >>> from sympy import Function, symbols
    >>> from sympy.physics.vector import init_vprinting
    >>> t, x = symbols('t, x')
    >>> omega = Function('omega')
    >>> omega(x).diff()
    Derivative(omega(x), x)
    >>> omega(t).diff()
    Derivative(omega(t), t)

    Now use the string printer:

    >>> init_vprinting(pretty_print=False)
    >>> omega(x).diff()
    Derivative(omega(x), x)
    >>> omega(t).diff()
    omega'

    """
    kwargs['str_printer'] = vsstrrepr
    kwargs['pretty_printer'] = vpprint
    kwargs['latex_printer'] = vlatex
    init_printing(**kwargs)
开发者ID:AkshaySiramdas,项目名称:sympy,代码行数:37,代码来源:printing.py

示例6: FlatPlate

from __future__ import division
from sympy.interactive import printing

printing.init_printing(use_latex="mathjax")


from IPython.display import display, Image, Latex
import numpy as np
import math
import scipy.constants as sc

import sympy as sym

# from sympy import *


class FlatPlate(object):
    """ Definition of boundary layer thickness, friction coefficient, Nusselt number (both local and average)
        as a function of the regime.
        import HT_external_convection_flat_plate.py as flatplate
        
        bl =flatplate.FlatPlate(regime,thermal_bc,U_infty,nu,alpha_f,L,xi,Re_xc)
        where 
        regime = 'laminar' or 'turbulent' or 'mixed', 
        thermal_bc = 'isothermal', 'heat flux', 'unheated starting length',
        U_infty is the free stream velocity,
        nu the fluid viscosity,
        alpha the fluid thermal diffusivity,
        L length of the plate
        xi unheated started length
        Re_xc critical Reynolds number for transition laminar to turbulence
开发者ID:yvesdubief,项目名称:UVM-ME144-Heat-Transfer,代码行数:31,代码来源:HT_external_convection_flat_plate.py

示例7: init_session

def init_session(ipython=None, pretty_print=True, order=None,
        use_unicode=None, quiet=False, auto_symbols=False, auto_int_to_Integer=False, argv=[]):
    """
    Initialize an embedded IPython or Python session. The IPython session is
    initiated with the --pylab option, without the numpy imports, so that
    matplotlib plotting can be interactive.

    Parameters
    ==========

    pretty_print: boolean
        If True, use pretty_print to stringify;
        if False, use sstrrepr to stringify.
    order: string or None
        There are a few different settings for this parameter:
        lex (default), which is lexographic order;
        grlex, which is graded lexographic order;
        grevlex, which is reversed graded lexographic order;
        old, which is used for compatibility reasons and for long expressions;
        None, which sets it to lex.
    use_unicode: boolean or None
        If True, use unicode characters;
        if False, do not use unicode characters.
    quiet: boolean
        If True, init_session will not print messages regarding its status;
        if False, init_session will print messages regarding its status.
    auto_symbols: boolean
        If True, IPython will automatically create symbols for you.
        If False, it will not.
        The default is False.
    auto_int_to_Integer: boolean
        If True, IPython will automatically wrap int literals with Integer, so
        that things like 1/2 give Rational(1, 2).
        If False, it will not.
        The default is False.
    ipython: boolean or None
        If True, printing will initialize for an IPython console;
        if False, printing will initialize for a normal console;
        The default is None, which does what False does.
    argv: list of arguments for IPython
        See sympy.bin.isympy for options that can be used to initialize IPython.

    See Also
    ========

    sympy.interactive.printing.init_printing: for examples and the rest of the parameters.


    Examples
    ========

    >>> from sympy import init_session, Symbol, sin, sqrt
    >>> sin(x) #doctest: +SKIP
    NameError: name 'x' is not defined
    >>> init_session() #doctest: +SKIP
    >>> sin(x) #doctest: +SKIP
    sin(x)
    >>> sqrt(5) #doctest: +SKIP
      ___
    \/ 5
    >>> init_session(pretty_print=False) #doctest: +SKIP
    >>> sqrt(5) #doctest: +SKIP
    sqrt(5)
    >>> y + x + y**2 + x**2 #doctest: +SKIP
    x**2 + x + y**2 + y
    >>> init_session(order='grlex') #doctest: +SKIP
    >>> y + x + y**2 + x**2 #doctest: +SKIP
    x**2 + y**2 + x + y
    >>> init_session(order='grevlex') #doctest: +SKIP
    >>> y * x**2 + x * y**2 #doctest: +SKIP
    x**2*y + x*y**2
    >>> init_session(order='old') #doctest: +SKIP
    >>> x**2 + y**2 + x + y #doctest: +SKIP
    x + y + x**2 + y**2
    >>> theta = Symbol('theta') #doctest: +SKIP
    >>> theta #doctest: +SKIP
    theta
    >>> init_session(use_unicode=True) #doctest: +SKIP
    >>> theta # doctest: +SKIP
    \u03b8
    """
    import sys

    in_ipython = False

    if ipython is False:
        ip = init_python_session()
        mainloop = ip.interact
    else:
        try:
            import IPython
        except ImportError:
            if ipython is not True:
                if not quiet:
                    print no_ipython
                ip = init_python_session()
                mainloop = ip.interact
            else:
                raise RuntimeError("IPython is not available on this system")
        else:
#.........这里部分代码省略.........
开发者ID:sn6uv,项目名称:sympy,代码行数:101,代码来源:session.py

示例8: init_printing

import sympy as s
from sympy.interactive.printing import init_printing
from sympy.matrices import Matrix
import numpy as np

init_printing(use_unicode=False, wrap_line=False, no_global=True)

# In [1]: %load_ext autoreload
#
# In [2]: %autoreload 2

class GradientDescentState(object):
    """holds the state for gradient descent"""

    def __init__(self, size, symbols, fn, initalGuess, grad):
        self.numberOfVariables = size
        self.x = symbols
        self.fn = fn
        self.initalGuess = initalGuess
        self.grad = grad

        self.currentIterValue = Matrix(initalGuess)

    # compute the gradient at point
    def atPoint(self, subs):
        if len(subs) != self.numberOfVariables:
            raise Exception('airity mismatch: atPoint')

        res = self.grad
        for idx in range(0, self.numberOfVariables):
            res = res.subs(self.x[idx], subs[idx]);
开发者ID:rogovski,项目名称:rogovski.github.io,代码行数:31,代码来源:gradient_descent.py

示例9: load_ipython_extension

def load_ipython_extension(ip):
    """Load the extension in IPython."""
    init_printing(ip=ip)
开发者ID:Abhityagi16,项目名称:sympy,代码行数:3,代码来源:ipythonprinting.py

示例10: symbols

"""Tools for setting up interactive sessions. """

from __future__ import print_function, division

from sympy.external import import_module
from sympy.interactive.printing import init_printing

preexec_source = """\
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()
"""

verbose_message = """\
These commands were executed:
%(source)s
Documentation can be found at http://www.sympy.org
"""

no_ipython = """\
Couldn't locate IPython. Having IPython installed is greatly recommended.
See http://ipython.scipy.org for more details. If you use Debian/Ubuntu,
just install the 'ipython' package and start isympy again.
"""


def _make_message(ipython=True, quiet=False, source=None):
    """Create a banner for an interactive session. """
开发者ID:B-Rich,项目名称:sympy,代码行数:31,代码来源:session.py

示例11: calculate_Integral

def calculate_Integral(expression,var1,var2,var3,varSup1,varSup2,varSup3,varInf1,varInf2,varInf3,\
                       typeIntegral,numDimensions,numColumns,\
                       showIntegral,showTime,numDigText,numerTypeIntegral,simplifyResult,outputResult):
    global nonCalculatedIntegral, nonCalculatedIntegralOutput, resultIntegral, resultIntegralSimp, resultOutput, timeIntegral

    init_printing(use_unicode=True, num_columns=numColumns)
    timet1=time.time()

    integrand = expression
    diffvar1 = var1.strip()
    diffvar2 = var2.strip()
    diffvar3 = var3.strip()
    limSup1 = varSup1.strip()
    limSup2 = varSup2.strip()
    limSup3 = varSup3.strip()
    limInf1 = varInf1.strip()
    limInf2 = varInf2.strip()
    limInf3 = varInf3.strip()

    integrateExpr = '('+integrand+','
    if typeIntegral == integralType['indefinite']:
        integrateExpr += diffvar1
        if numDimensions > 1:
            integrateExpr += ','+diffvar2
        if numDimensions > 2:
            integrateExpr += ','+diffvar3
        integrateExpr += ')'
        try:
            nonCalculatedIntegral = sympify('Integral'+integrateExpr)
        except:
            nonCalculatedIntegral = 'Integral'+integrateExpr
        try:
            resultIntegral = sympify('integrate'+integrateExpr)
        except:
            resultIntegral = integralErrorMessage
    else:
        integrateExpr += '('+diffvar1+','+limInf1+','+limSup1+')'
        if numDimensions > 1:
            integrateExpr += ',('+diffvar2+','+limInf2+','+limSup2+')'
        if numDimensions > 2:
            integrateExpr += ',('+diffvar3+','+limInf3+','+limSup3+')'
        integrateExpr += ')'
        try:
            nonCalculatedIntegral = sympify('Integral'+integrateExpr)
        except:
            nonCalculatedIntegral = 'Integral'+integrateExpr
        if typeIntegral == integralType['definite']:
            try:
                resultIntegral = sympify('integrate'+integrateExpr)
            except:
                resultIntegral = integralErrorMessage
        else:
            if numerTypeIntegral == numerIntegralType['approx']:
                try:
                    resultIntegral = sympify('N(integrate'+integrateExpr+','+numDigText+')')
                except:
                    resultIntegral = integralErrorMessage
            else:
                mp.dps=int(numDigText)
                integrateExpr = "(lambda "
                if numDimensions > 2:
                    integrateExpr += diffvar3+","
                if numDimensions > 1:
                    integrateExpr += diffvar2+","
                integrand = fixMPMathText(integrand)
                integrateExpr += diffvar1+": "+integrand
                if numDimensions > 2:
                    limInf3 = fixMPMathText(limInf3)
                    limSup3 = fixMPMathText(limSup3)
                    integrateExpr += ',['+limInf3+','+limSup3+']'
                if numDimensions > 1:
                    limInf2 = fixMPMathText(limInf2)
                    limSup2 = fixMPMathText(limSup2)
                    integrateExpr += ',['+limInf2+','+limSup2+']'
                limInf1 = fixMPMathText(limInf1)
                limSup1 = fixMPMathText(limSup1)
                integrateExpr += ",["+limInf1+","+limSup1+"])"
                try:
                    if numerTypeIntegral == numerIntegralType['infinities']:
                        resultIntegral = eval("quadts"+integrateExpr)
                    else:
                        resultIntegral = eval("quadgl"+integrateExpr)
                    resultIntegral = sympify('N('+fixMPMathOutput(str(resultIntegral))+','+numDigText+')')
                except:
                    resultIntegral = integralNumerErrorMessage

    if (resultIntegral) and (type(resultIntegral) != str) and (typeIntegral != integralType['numerical']):
        if simplifyResult == simplifyType['none']:
            resultIntegralSimp = sympify(resultIntegral)
        elif simplifyResult == simplifyType['expandterms']:
            resultIntegralSimp = sympify(mapexpr(resultIntegral,expand))
        elif simplifyResult == simplifyType['simplifyterms']:
            resultIntegralSimp = sympify(mapexpr(resultIntegral,simplify))
        elif simplifyResult == simplifyType['expandall']:
            resultIntegralSimp = sympify(expand(resultIntegral))
        elif simplifyResult == simplifyType['simplifyall']:
            resultIntegralSimp = sympify(simplify(resultIntegral))
    else:
        resultIntegralSimp = resultIntegral

#.........这里部分代码省略.........
开发者ID:rcolistete,项目名称:integral-sailfish,代码行数:101,代码来源:integral.py

示例12: init_session

def init_session(ipython=None, pretty_print=True, order=None,
        use_unicode=None, use_latex=None, quiet=False, auto_symbols=False,
        auto_int_to_Integer=False, str_printer=None, pretty_printer=None,
        latex_printer=None, argv=[]):
    """
    Initialize an embedded IPython or Python session. The IPython session is
    initiated with the --pylab option, without the numpy imports, so that
    matplotlib plotting can be interactive.

    Parameters
    ==========

    pretty_print: boolean
        If True, use pretty_print to stringify;
        if False, use sstrrepr to stringify.
    order: string or None
        There are a few different settings for this parameter:
        lex (default), which is lexographic order;
        grlex, which is graded lexographic order;
        grevlex, which is reversed graded lexographic order;
        old, which is used for compatibility reasons and for long expressions;
        None, which sets it to lex.
    use_unicode: boolean or None
        If True, use unicode characters;
        if False, do not use unicode characters.
    use_latex: boolean or None
        If True, use latex rendering if IPython GUI's;
        if False, do not use latex rendering.
    quiet: boolean
        If True, init_session will not print messages regarding its status;
        if False, init_session will print messages regarding its status.
    auto_symbols: boolean
        If True, IPython will automatically create symbols for you.
        If False, it will not.
        The default is False.
    auto_int_to_Integer: boolean
        If True, IPython will automatically wrap int literals with Integer, so
        that things like 1/2 give Rational(1, 2).
        If False, it will not.
        The default is False.
    ipython: boolean or None
        If True, printing will initialize for an IPython console;
        if False, printing will initialize for a normal console;
        The default is None, which automatically determines whether we are in
        an ipython instance or not.
    str_printer: function, optional, default=None
        A custom string printer function. This should mimic
        sympy.printing.sstrrepr().
    pretty_printer: function, optional, default=None
        A custom pretty printer. This should mimic sympy.printing.pretty().
    latex_printer: function, optional, default=None
        A custom LaTeX printer. This should mimic sympy.printing.latex()
        This should mimic sympy.printing.latex().
    argv: list of arguments for IPython
        See sympy.bin.isympy for options that can be used to initialize IPython.

    See Also
    ========

    sympy.interactive.printing.init_printing: for examples and the rest of the parameters.


    Examples
    ========

    >>> from sympy import init_session, Symbol, sin, sqrt
    >>> sin(x) #doctest: +SKIP
    NameError: name 'x' is not defined
    >>> init_session() #doctest: +SKIP
    >>> sin(x) #doctest: +SKIP
    sin(x)
    >>> sqrt(5) #doctest: +SKIP
      ___
    \/ 5
    >>> init_session(pretty_print=False) #doctest: +SKIP
    >>> sqrt(5) #doctest: +SKIP
    sqrt(5)
    >>> y + x + y**2 + x**2 #doctest: +SKIP
    x**2 + x + y**2 + y
    >>> init_session(order='grlex') #doctest: +SKIP
    >>> y + x + y**2 + x**2 #doctest: +SKIP
    x**2 + y**2 + x + y
    >>> init_session(order='grevlex') #doctest: +SKIP
    >>> y * x**2 + x * y**2 #doctest: +SKIP
    x**2*y + x*y**2
    >>> init_session(order='old') #doctest: +SKIP
    >>> x**2 + y**2 + x + y #doctest: +SKIP
    x + y + x**2 + y**2
    >>> theta = Symbol('theta') #doctest: +SKIP
    >>> theta #doctest: +SKIP
    theta
    >>> init_session(use_unicode=True) #doctest: +SKIP
    >>> theta # doctest: +SKIP
    \u03b8
    """
    import sys

    in_ipython = False

    if ipython is not False:
#.........这里部分代码省略.........
开发者ID:alexako,项目名称:sympy,代码行数:101,代码来源:session.py

示例13: symbols

# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>

# <codecell>

from IPython.display import display

from sympy.interactive import printing
printing.init_printing()

from __future__ import division
import sympy as sym
from sympy import *


import matplotlib
matplotlib.rc('font',**{'family':'serif'})

# <markdowncell>

# # Outline of the HTSE solution to second order

# <codecell>

z0, z, u, B, t , U= symbols(r"z_{0} z u \beta t U")
m=6.
grand = -sym.log( z0 ) / B - B * (t/z0)**2 * m * ( z + z**3 * u + 2*z**2 * (1-u) / (B*U))
grand

# <codecell>
开发者ID:PedroMDuarte,项目名称:lattice_3D_ipynb,代码行数:30,代码来源:HubbardPhaseDiagram.py

示例14: init_mprinting

def init_mprinting():
    init_printing(pretty_print=False, str_printer=mstr)
开发者ID:worldmaker18349276,项目名称:magicpy,代码行数:2,代码来源:strplus.py

示例15: init_printing

# coding: utf-8

# In[1]:

from sympy import *
from sympy.interactive.printing import init_printing
init_printing()


# In[2]:

from sympa import domath


# In[3]:

import pandas as pd


# In[4]:

df = pd.DataFrame({'x' : range(7)})
df['x'] = df.x * 10
df['y'] = df.x * 0.05
df['r'] = pi * df['y'] / 2
df


# In[5]:
开发者ID:pombredanne,项目名称:sympa,代码行数:29,代码来源:Sympa+Example.py


注:本文中的sympy.interactive.printing.init_printing函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。