code stringlengths 17 6.64M |
|---|
class R(ExtraTabCompletion, Interface):
def __init__(self, maxread=None, logfile=None, init_list_length=1024, seed=None):
"\n An interface to the R interpreter.\n\n R is a comprehensive collection of methods for statistics,\n modelling, bioinformatics, data analysis and much more.\n ... |
@instancedoc
class RElement(ExtraTabCompletion, InterfaceElement):
def _tab_completion(self):
'\n Return a list of all methods of this object.\n\n .. note::\n\n Currently returns all R commands.\n\n EXAMPLES::\n\n sage: a = r([1,2,3]) # optional - rpy2\n ... |
@instancedoc
class RFunctionElement(InterfaceFunctionElement):
def __reduce__(self):
'\n EXAMPLES::\n\n sage: a = r([1,2,3]) # optional - rpy2\n sage: a.mean # optional - rpy2\n mean\n sage: dumps(a.mean) # optional - rpy2\n Traceback (most... |
@instancedoc
class RFunction(InterfaceFunction):
def __init__(self, parent, name, r_name=None):
"\n A Function in the R interface.\n\n INPUT:\n\n - parent -- the R interface\n - name -- the name of the function for Python\n - r_name -- the name of the function in R itse... |
def is_RElement(x):
'\n Return True if x is an element in an R interface.\n\n INPUT:\n\n - x -- object\n\n OUTPUT: bool\n\n EXAMPLES::\n\n sage: from sage.interfaces.r import is_RElement # optional - rpy2\n sage: is_RElement(2) # optional - rpy2\n doctest:...: DeprecationWarn... |
def reduce_load_R():
'\n Used for reconstructing a copy of the R interpreter from a pickle.\n\n EXAMPLES::\n\n sage: from sage.interfaces.r import reduce_load_R # optional - rpy2\n sage: reduce_load_R() # optional - rpy2\n R Interpreter\n '
return r
|
def r_console():
'\n Spawn a new R command-line session.\n\n EXAMPLES::\n\n sage: r.console() # not tested # optional - rpy2\n R version 2.6.1 (2007-11-26)\n Copyright (C) 2007 The R Foundation for Statistical Computing\n ISBN 3-900051-07-0\n ... |
def r_version():
"\n Return the R version.\n\n EXAMPLES::\n\n sage: # optional - rpy2\n sage: r_version() # not tested\n ((3, 0, 1), 'R version 3.0.1 (2013-05-16)')\n sage: rint, rstr = r_version()\n sage: rint[0] >= 3\n True\n sage: rst... |
class HelpExpression(str):
'\n Used to improve printing of output of r.help.\n '
def __repr__(self):
'\n Return string representation of ``self``.\n\n OUTPUT: string\n\n EXAMPLES::\n\n sage: a = sage.interfaces.r.HelpExpression("This\\nis\\nR!") # optional - rpy... |
def read_data(f, t):
'\n Read data from file \'f\' and class \'t\' (one element per line),\n and returns a list of elements.\n\n INPUT:\n\n - \'f\' -- a file name\n - \'t\' -- a class (objects will be coerced to that class)\n\n OUTPUT:\n\n a list of elements of class \'t\'\n\n EXAMPLES::\n... |
class SingNot():
'\n This class is to resolve difference between various Singmaster notation.\n\n Case is ignored, and the second and third letters may be swapped.\n\n EXAMPLES::\n\n sage: from sage.interfaces.rubik import SingNot\n sage: SingNot("acb") == SingNot("ACB")\n True\n ... |
class OptimalSolver():
"\n Interface to Michael Reid's optimal Rubik's Cube solver.\n "
def __init__(self, verbose=False, wait=True):
self.verbose = verbose
self.start()
if wait:
print('Initializing tables...')
self.ready()
print('Done.')
... |
class CubexSolver():
def __call__(self, facets):
return self.solve(facets)
def solve(self, facets):
'\n EXAMPLES::\n\n sage: # optional - rubiks\n sage: from sage.interfaces.rubik import *\n sage: C = RubiksCube("R U")\n sage: CubexSolver().... |
class DikSolver():
def __call__(self, facets):
return self.solve(facets)
def solve(self, facets, timeout=10, extra_time=2):
'\n EXAMPLES::\n\n sage: # optional - rubiks\n sage: from sage.interfaces.rubik import *\n sage: C = RubiksCube().move("R U")\n ... |
class Sage(ExtraTabCompletion, Expect):
'\n Expect interface to the Sage interpreter itself.\n\n INPUT:\n\n\n - ``server`` - (optional); if specified runs Sage on a\n remote machine with address. You must have ssh keys setup so you\n can login to the remote machine by typing "ssh remote_mach... |
@instancedoc
class SageElement(ExpectElement):
def _rich_repr_(self, display_manager, **kwds):
'\n Disable rich output\n\n This is necessary because otherwise our :meth:`__getattr__`\n would be called.\n\n EXAMPLES::\n\n sage: from sage.repl.rich_output import get_d... |
@instancedoc
class SageFunction(FunctionElement):
def __call__(self, *args, **kwds):
'\n EXAMPLES::\n\n sage: four_gcd = sage0(4).gcd\n sage: four_gcd(6)\n 2\n '
P = self._obj.parent()
args = [P(x) for x in args]
kwds = [(k, P(v)) for... |
def reduce_load_Sage():
'\n EXAMPLES::\n\n sage: from sage.interfaces.sage0 import reduce_load_Sage\n sage: reduce_load_Sage()\n Sage\n '
return sage0
|
def reduce_load_element(s):
'\n EXAMPLES::\n\n sage: from sage.interfaces.sage0 import reduce_load_element\n sage: s = dumps(1/2)\n sage: half = reduce_load_element(s); half\n 1/2\n sage: half.parent()\n Sage\n '
import base64
s = base64.b32encode(s)
sag... |
def sage0_console():
'\n Spawn a new Sage command-line session.\n\n EXAMPLES::\n\n sage: sage0_console() #not tested\n ----------------------------------------------------------------------\n | SageMath version ..., Release Date: ... |\n | Using Python ... |
def sage0_version():
'\n EXAMPLES::\n\n sage: from sage.interfaces.sage0 import sage0_version\n sage: sage0_version() == version()\n True\n '
return str(sage0('version()'))
|
class Scilab(Expect):
"\n Interface to the Scilab interpreter.\n\n EXAMPLES::\n\n sage: # optional - scilab\n sage: a = scilab('[ 1, 1, 2; 3, 5, 8; 13, 21, 33 ]')\n sage: b = scilab('[ 1; 3; 13]')\n sage: c = a * b\n sage: print(c)\n 30.\n 122.\n ... |
@instancedoc
class ScilabElement(ExpectElement):
def __getitem__(self, n):
"\n Use parenthesis for Scilab matrices instead.\n\n EXAMPLES::\n\n sage: # optional - scilab\n sage: M = scilab('[1,2,3;4,5,6;7,8,9]')\n sage: M[1]\n 1.\n sage:... |
def scilab_console():
'\n This requires that the optional Scilab program be installed and in\n your PATH, but no optional Sage packages need to be installed.\n\n EXAMPLES::\n\n sage: from sage.interfaces.scilab import scilab_console # optional - scilab\n sage: scilab_console() ... |
def scilab_version():
"\n Return the version of Scilab installed.\n\n EXAMPLES::\n\n sage: from sage.interfaces.scilab import scilab_version # optional - scilab\n sage: scilab_version() # optional - scilab\n 'scilab-...'\n "
return str(scilab('getversion()')).strip()
|
class SingularError(RuntimeError):
'\n Raised if Singular printed an error message\n '
pass
|
class Singular(ExtraTabCompletion, Expect):
"\n Interface to the Singular interpreter.\n\n EXAMPLES: A Groebner basis example.\n\n ::\n\n sage: R = singular.ring(0, '(x0,x1,x2)', 'lp')\n sage: I = singular.ideal([ 'x0*x1*x2 -x0^2*x2', 'x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2', 'x0*x1-x0*x2-x1*x2']... |
@instancedoc
class SingularElement(ExtraTabCompletion, ExpectElement, sage.interfaces.abc.SingularElement):
def __init__(self, parent, type, value, is_name=False):
'\n EXAMPLES::\n\n sage: a = singular(2)\n sage: loads(dumps(a))\n 2\n '
RingElement._... |
@instancedoc
class SingularFunction(ExpectFunction):
def _instancedoc_(self):
"\n EXAMPLES::\n\n sage: 'groebner' in singular.groebner.__doc__\n True\n "
if (not nodes):
generate_docstring_dictionary()
prefix = ("\nThis function is an automa... |
@instancedoc
class SingularFunctionElement(FunctionElement):
def _instancedoc_(self):
"\n EXAMPLES::\n\n sage: R = singular.ring(0, '(x,y,z)', 'dp')\n sage: A = singular.matrix(2,2)\n sage: 'matrix_expression' in A.nrows.__doc__\n True\n "
... |
def is_SingularElement(x):
'\n Return True is ``x`` is of type :class:`SingularElement`.\n\n This function is deprecated; use :func:`isinstance`\n (of :class:`sage.interfaces.abc.SingularElement`) instead.\n\n EXAMPLES::\n\n sage: from sage.interfaces.singular import is_SingularElement\n ... |
def generate_docstring_dictionary():
'\n Generate global dictionaries which hold the docstrings for\n Singular functions.\n\n EXAMPLES::\n\n sage: from sage.interfaces.singular import generate_docstring_dictionary\n sage: generate_docstring_dictionary()\n '
global nodes
global no... |
def get_docstring(name):
"\n Return the docstring for the function ``name``.\n\n INPUT:\n\n - ``name`` - a Singular function name\n\n EXAMPLES::\n\n sage: from sage.interfaces.singular import get_docstring\n sage: 'groebner' in get_docstring('groebner')\n True\n sage: 'stan... |
def reduce_load_Singular():
'\n EXAMPLES::\n\n sage: from sage.interfaces.singular import reduce_load_Singular\n sage: reduce_load_Singular()\n Singular\n '
return singular
|
def singular_console():
'\n Spawn a new Singular command-line session.\n\n EXAMPLES::\n\n sage: singular_console() #not tested\n SINGULAR / Development\n A Computer Algebra System for Polynomial Computations / version 3-0-4\n ... |
def singular_version():
'\n Return the version of Singular being used.\n\n EXAMPLES::\n\n sage: singular.version()\n "Singular ... version 4...\n '
return singular.eval('system("--version");')
|
class SingularGBLogPrettyPrinter():
'\n A device which prints Singular Groebner basis computation logs\n more verbatim.\n '
rng_chng = re.compile('\\[\\d+:\\d+\\]')
new_elem = re.compile('s')
red_zero = re.compile('-')
red_post = re.compile('\\.')
cri_hilb = re.compile('h')
hig_co... |
class SingularGBDefaultContext():
'\n Within this context all Singular Groebner basis calculations are\n reduced automatically.\n\n AUTHORS:\n\n - Martin Albrecht\n - Simon King\n '
def __init__(self, singular=None):
"\n Within this context all Singular Groebner basis calcula... |
def singular_gb_standard_options(func):
'\n Decorator to force a reduced Singular groebner basis.\n\n TESTS::\n\n sage: P.<a,b,c,d,e> = PolynomialRing(GF(127))\n sage: J = sage.rings.ideal.Cyclic(P).homogenize()\n sage: from sage.misc.sageinspect import sage_getsource\n sage: "ba... |
def _sympysage_float(self):
"\n EXAMPLES::\n\n sage: from sympy.core.numbers import RealNumber as RN\n sage: assert SR(-1.34)._sympy_() == RN('-1.34')\n sage: assert SR(-1.34) == RN('-1.34')._sage_()\n "
from sage.rings.real_mpfr import create_RealNumber
return create_RealNumber... |
def _sympysage_integer_ring(self):
'\n EXAMPLES::\n\n sage: import sympy\n sage: sympy.ZZ._sage_()\n Integer Ring\n '
from sage.rings.integer_ring import ZZ
return ZZ
|
def _sympysage_integer(self):
"\n EXAMPLES::\n\n sage: from sympy.core.numbers import Integer as SympyInt\n sage: assert SR(2)._sympy_() == SympyInt(int(2))\n sage: assert SR(2) == SympyInt(int(2))._sage_()\n sage: type(SympyInt(int(2))._sage_())\n <class 'sage.rings.integer.... |
def _sympysage_rational(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import Rational\n sage: assert SR(-5/7)._sympy_() == Rational(int(-5),int(7))\n sage: assert SR(-5/7) == Rational(int(-5),int(7))._sage_()\n '
from sage.rings.integer import Integer
from sage.rings.r... |
def _sympysage_rational_field(self):
'\n EXAMPLES::\n\n sage: import sympy\n sage: sympy.QQ._sage_()\n Rational Field\n '
from sage.rings.rational_field import QQ
return QQ
|
def _sympysage_real_interval(self):
'\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import sympy_init\n sage: sympy_init()\n\n sage: from sympy import CRootOf\n sage: from sympy.abc import x\n sage: root = CRootOf(x**3 - x^2 - x - 1, 0)\n sage: interval = root._get... |
def _sympysage_complex_interval(self):
'\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import sympy_init\n sage: sympy_init()\n\n sage: from sympy import CRootOf\n sage: from sympy.abc import x\n sage: root = CRootOf(x**10 - 2*x + 3, 9)\n sage: interval = root._get... |
def _sympysage_polynomial_ring(self):
"\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import sympy_init\n sage: sympy_init()\n\n sage: import sympy\n sage: ZZx = sympy.PolynomialRing(sympy.ZZ, 'x')\n sage: ZZx._sage_()\n Univariate Polynomial Ring in x over Integer... |
def _sympysage_polynomial(self):
'\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import sympy_init\n sage: sympy_init()\n\n sage: import sympy\n sage: from sympy.abc import x, y\n sage: p = sympy.Poly(x*(x**2 + x - 1)**2)\n sage: p._sage_()\n x^5 + 2*x^4 - x... |
def _sympysage_pinfty(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import oo as sinf\n sage: assert SR(oo)._sympy_() == sinf\n sage: assert SR(oo) == sinf._sage_()\n '
from sage.rings.infinity import PlusInfinity
return PlusInfinity()
|
def _sympysage_ninfty(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import oo as sinf\n sage: assert SR(-oo)._sympy_() == -sinf\n sage: assert SR(-oo) == (-sinf)._sage_()\n '
from sage.rings.infinity import MinusInfinity
return MinusInfinity()
|
def _sympysage_uinfty(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import zoo\n sage: assert unsigned_infinity._sympy_() == zoo\n sage: assert unsigned_infinity == zoo._sage_()\n '
from sage.rings.infinity import unsigned_infinity
return unsigned_infinity
|
def _sympysage_nan(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import nan as snan\n sage: assert NaN._sympy_() == snan\n sage: assert NaN == snan._sage_()\n '
from sage.symbolic.constants import NaN
return NaN
|
def _sympysage_e(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import E\n sage: assert e._sympy_() == E\n sage: assert e == E._sage_()\n '
from sage.symbolic.constants import e
return e
|
def _sympysage_pi(self):
'\n EXAMPLES::\n\n sage: from sympy.core.numbers import pi as spi\n sage: assert pi._sympy_() == spi\n sage: assert pi == spi._sage_()\n '
from sage.symbolic.constants import pi
return pi
|
def _sympysage_golden_ratio(self):
'\n EXAMPLES::\n\n sage: from sympy.core.singleton import S\n sage: assert golden_ratio._sympy_() == S.GoldenRatio\n sage: assert golden_ratio == S.GoldenRatio._sage_()\n '
from sage.symbolic.constants import golden_ratio
return golden_ratio
|
def _sympysage_eulerg(self):
'\n EXAMPLES::\n\n sage: from sympy.core.singleton import S\n sage: assert euler_gamma._sympy_() == S.EulerGamma\n sage: assert euler_gamma == S.EulerGamma._sage_()\n '
from sage.symbolic.constants import euler_gamma
return euler_gamma
|
def _sympysage_catalan(self):
'\n EXAMPLES::\n\n sage: from sympy.core.singleton import S\n sage: assert catalan._sympy_() == S.Catalan\n sage: assert catalan == S.Catalan._sage_()\n '
from sage.symbolic.constants import catalan
return catalan
|
def _sympysage_i(self):
'\n EXAMPLES::\n\n sage: from sympy.core.singleton import S\n sage: assert I._sympy_() == S.ImaginaryUnit\n sage: assert I == S.ImaginaryUnit._sage_()\n '
from sage.symbolic.constants import I
return I
|
def _sympysage_add(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol\n sage: from sympy.core.singleton import S\n sage: assert (x-pi+1)._sympy_() == Symbol('x')-S.Pi+1\n sage: assert x-pi+1 == (Symbol('x')-S.Pi+1)._sage_()\n "
s = 0
for x in self.args:
s +=... |
def _sympysage_mul(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol\n sage: from sympy.core.singleton import S\n sage: assert (-x*pi*5)._sympy_() == -Symbol('x')*S.Pi*5\n sage: assert -x*pi*5 == (-Symbol('x')*S.Pi*5)._sage_()\n "
s = 1
for x in self.args:
... |
def _sympysage_pow(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol\n sage: from sympy.core.singleton import S\n sage: assert (x^pi^5)._sympy_() == Symbol('x')**S.Pi**5\n sage: assert x^pi^5 == (Symbol('x')**S.Pi**5)._sage_()\n "
return (self.args[0]._sage_() ** self.... |
def _sympysage_symbol(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol\n sage: assert x._sympy_() == Symbol('x')\n sage: assert x == Symbol('x')._sage_()\n "
from sage.symbolic.ring import SR
try:
return SR.var(self.name)
except ValueError:
return SR.... |
def _sympysage_Subs(self):
'\n EXAMPLES::\n\n sage: from sympy import Symbol\n sage: from sympy.core.singleton import S\n '
args = self.args
substi = dict([(args[1][i]._sage_(), args[2][i]._sage_()) for i in range(len(args[1]))])
return args[0]._sage_().subs(substi)
|
def _sympysage_function_by_name(fname):
"\n Given a sympy function with name ``fname`` find the corresponding\n sage function or create a new one with the given name.\n\n EXAMPLES::\n\n sage: from sympy import Function\n sage: f = function('f')\n sage: F = Function('f')\n sage... |
class UndefSageHelper():
"\n Helper class to convert sympy function objects to sage functions\n\n EXAMPLES::\n\n sage: from sympy import Function\n sage: f = function('f')\n sage: F = Function('f')\n sage: assert f._sympy_() == F\n sage: assert f == F._sage_()\n "
... |
def _sympysage_function(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, Function, sin as Sin\n sage: assert sin(x)._sympy_() == Sin(Symbol('x'))\n sage: assert sin(x) == Sin(Symbol('x'))._sage_()\n\n sage: f = function('f')\n sage: F = Function('f')\n sage: a... |
def _sympysage_integral(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, Integral\n sage: sx = Symbol('x')\n sage: assert integral(x, x, hold=True)._sympy_() == Integral(sx, sx)\n sage: assert integral(x, x, hold=True) == Integral(sx, sx)._sage_()\n sage: assert inte... |
def _sympysage_derivative(self):
"\n EXAMPLES::\n\n sage: from sympy import Derivative\n sage: f = function('f')\n sage: sympy_diff = Derivative(f(x)._sympy_(), x._sympy_())\n sage: assert diff(f(x),x)._sympy_() == sympy_diff\n sage: assert diff(f(x),x) == sympy_diff._sage_()... |
def _sympysage_order(self):
'\n EXAMPLES::\n\n sage: from sage.functions.other import Order\n sage: from sympy.series import Order as SOrder\n sage: assert Order(1)._sympy_() == SOrder(1)\n sage: assert Order(1) == SOrder(1)._sage_()\n '
from sage.functions.other import Order... |
def _sympysage_lambertw(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, LambertW\n sage: assert lambert_w(x)._sympy_() == LambertW(0, Symbol('x'))\n sage: assert lambert_w(x) == LambertW(Symbol('x'))._sage_()\n "
from sage.functions.log import lambert_w
return lambert_... |
def _sympysage_rf(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, rf\n sage: _ = var('x, y')\n sage: rfxy = rf(Symbol('x'), Symbol('y'))\n sage: assert rising_factorial(x,y)._sympy_() == rfxy.rewrite('gamma', piecewise=False)\n sage: assert rising_factorial(x,y) == ... |
def _sympysage_ff(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, ff\n sage: _ = var('x, y')\n sage: ffxy = ff(Symbol('x'), Symbol('y'))\n sage: assert falling_factorial(x,y)._sympy_() == ffxy.rewrite('gamma') # known bug\n sage: assert falling_factorial(x,y) == ffx... |
def _sympysage_lgamma(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, loggamma\n sage: assert log_gamma(x)._sympy_() == loggamma(Symbol('x'))\n sage: assert log_gamma(x) == loggamma(Symbol('x'))._sage_()\n "
from sage.functions.gamma import log_gamma
return log_gamma(s... |
def _sympysage_polygamma(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, polygamma as pg\n sage: _ = var('x, y')\n sage: pgxy = pg(Symbol('x'), Symbol('y'))\n sage: assert psi(x)._sympy_() == pg(0, Symbol('x'))\n sage: assert psi(x) == pg(0, Symbol('x'))._sage_()\n ... |
def _sympysage_dirac_delta(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, DiracDelta\n sage: assert dirac_delta(x)._sympy_() == DiracDelta(Symbol('x'))\n sage: assert dirac_delta(x) == DiracDelta(Symbol('x'))._sage_()\n "
from sage.functions.generalized import dirac_delta... |
def _sympysage_heaviside(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, Heaviside\n sage: assert heaviside(x)._sympy_() == Heaviside(Symbol('x'))\n sage: assert heaviside(x) == Heaviside(Symbol('x'))._sage_()\n "
from sage.functions.generalized import heaviside
return... |
def _sympysage_expint(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, expint\n sage: _ = var('x, y')\n sage: sy = expint(Symbol('x'), Symbol('y'))\n sage: assert exp_integral_e(x,y)._sympy_() == sy\n sage: assert exp_integral_e(x,y) == sy._sage_()\n "
from sa... |
def _sympysage_hyp(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, hyper\n sage: _ = var('a,b,p,q,x')\n sage: sy = hyper((Symbol('a'), Symbol('b')), (Symbol('p'), Symbol('q')), Symbol('x'))\n sage: assert hypergeometric((a,b),(p,q),x)._sympy_() == sy\n sage: assert ... |
def _sympysage_elliptic_k(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, elliptic_k\n sage: assert elliptic_kc(x)._sympy_() == elliptic_k(Symbol('x'))\n sage: assert elliptic_kc(x) == elliptic_k(Symbol('x'))._sage_()\n "
from sage.functions.special import elliptic_kc
... |
def _sympysage_kronecker_delta(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, KroneckerDelta\n sage: _ = var('x, y')\n sage: sy = KroneckerDelta(Symbol('x'), Symbol('y'))\n sage: assert kronecker_delta(x,y)._sympy_() == sy\n sage: assert kronecker_delta(x,y) == sy.... |
def _sympysage_ceiling(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, ceiling\n sage: assert ceil(x)._sympy_() == ceiling(Symbol('x'))\n sage: assert ceil(x) == ceiling(Symbol('x'))._sage_()\n sage: integrate(ceil(x), x, 0, infinity, algorithm='sympy')\n integrate(... |
def _sympysage_piecewise(self):
'\n EXAMPLES::\n\n sage: from sympy import Symbol, pi as spi, Eq, Lt, Piecewise\n sage: sx = Symbol(\'x\')\n sage: sp = Piecewise((spi, Lt(sx,0)), (1, Eq(sx,1)), (0, True))\n sage: ex = cases(((x<0, pi), (x==1, 1), (True, 0)))\n sage: assert ex... |
def _sympysage_fresnels(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, pi as spi, fresnels\n sage: sx = Symbol('x')\n sage: sp = fresnels(sx)\n sage: ex = fresnel_sin(x)\n sage: assert ex._sympy_() == sp\n sage: assert ex == sp._sage_()\n "
from sage... |
def _sympysage_fresnelc(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, pi as spi, fresnelc\n sage: sx = Symbol('x')\n sage: sp = fresnelc(sx)\n sage: ex = fresnel_cos(x)\n sage: assert ex._sympy_() == sp\n sage: assert ex == sp._sage_()\n "
from sage... |
def _sympysage_besselj(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, besselj\n sage: _ = var('x, y')\n sage: sy = besselj(Symbol('x'), Symbol('y'))\n sage: assert bessel_J(x,y)._sympy_() == sy\n sage: assert bessel_J(x,y) == sy._sage_()\n "
from sage.functi... |
def _sympysage_bessely(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, bessely\n sage: _ = var('x, y')\n sage: sy = bessely(Symbol('x'), Symbol('y'))\n sage: assert bessel_Y(x,y)._sympy_() == sy\n sage: assert bessel_Y(x,y) == sy._sage_()\n "
from sage.functi... |
def _sympysage_besseli(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, besseli\n sage: _ = var('x, y')\n sage: sy = besseli(Symbol('x'), Symbol('y'))\n sage: assert bessel_I(x,y)._sympy_() == sy\n sage: assert bessel_I(x,y) == sy._sage_()\n "
from sage.functi... |
def _sympysage_besselk(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, besselk\n sage: _ = var('x, y')\n sage: sy = besselk(Symbol('x'), Symbol('y'))\n sage: assert bessel_K(x,y)._sympy_() == sy\n sage: assert bessel_K(x,y) == sy._sage_()\n "
from sage.functi... |
def _sympysage_ynm(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, Ynm\n sage: _ = var('n,m,t,p')\n sage: sy = Ynm(Symbol('n'), Symbol('m'), Symbol('t'), Symbol('p'))\n sage: assert spherical_harmonic(n,m,t,p)._sympy_() == sy\n sage: assert spherical_harmonic(n,m,t,... |
def _sympysage_re(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, re\n sage: assert real_part(x)._sympy_() == re(Symbol('x'))\n sage: assert real_part(x) == re(Symbol('x'))._sage_()\n "
from sage.functions.other import real_part
return real_part(self.args[0]._sage_())
|
def _sympysage_im(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, im\n sage: assert imag_part(x)._sympy_() == im(Symbol('x'))\n sage: assert imag_part(x) == im(Symbol('x'))._sage_()\n "
from sage.functions.other import imag_part
return imag_part(self.args[0]._sage_())
|
def _sympysage_abs(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, Abs\n sage: assert abs(x)._sympy_() == Abs(Symbol('x'))\n sage: assert abs(x) == Abs(Symbol('x'))._sage_()\n "
from sage.functions.other import abs_symbolic
return abs_symbolic(self.args[0]._sage_())
|
def _sympysage_crootof(self):
"\n EXAMPLES::\n\n sage: from sympy import Symbol, CRootOf\n sage: sobj = CRootOf(Symbol('x')**2 - 2, 1)\n sage: assert complex_root_of(x^2-2, 1)._sympy_() == sobj\n sage: assert complex_root_of(x^2-2, 1) == sobj._sage_()\n\n sage: from sympy imp... |
def _sympysage_matrix(self):
'\n Convert SymPy matrix ``self`` to Sage.\n\n EXAMPLES::\n\n sage: from sympy.matrices import Matrix, SparseMatrix, ImmutableMatrix\n sage: from sage.interfaces.sympy import sympy_init\n sage: from sympy.abc import x\n sage: sympy_init()\n sag... |
def _sympysage_relational(self):
"\n EXAMPLES::\n\n sage: from sympy import Eq, Ne, Gt, Ge, Lt, Le, Symbol\n sage: sx = Symbol('x')\n sage: assert (x == 0)._sympy_() == Eq(sx, 0)\n sage: assert (x == 0) == Eq(x, 0)._sage_()\n sage: assert (x != 0)._sympy_() == Ne(sx, 0)\n ... |
def _sympysage_false(self):
'\n EXAMPLES::\n\n sage: from sympy.logic.boolalg import BooleanFalse\n sage: assert SR(False)._sympy_() == BooleanFalse() # known bug\n sage: assert SR(False) == BooleanFalse()._sage_()\n '
from sage.symbolic.ring import SR
return SR(False)
|
def _sympysage_true(self):
'\n EXAMPLES::\n\n sage: from sympy.logic.boolalg import BooleanTrue\n sage: assert SR(True)._sympy_() == BooleanTrue() # known bug\n sage: assert SR(True) == BooleanTrue()._sage_()\n '
from sage.symbolic.ring import SR
return SR(True)
|
@run_once
def sympy_init():
"\n Add ``_sage_()`` methods to SymPy objects where needed.\n\n This gets called with every call to ``Expression._sympy_()``\n so there is only need to call it if you bypass ``_sympy_()`` to\n create SymPy objects. Note that SymPy objects have ``_sage_()``\n methods hard... |
def check_expression(expr, var_symbols, only_from_sympy=False):
'\n Does ``eval(expr)`` both in Sage and SymPy and does other checks.\n\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import check_expression\n sage: check_expression("1.123*x", "x")\n '
from sage.symbolic.ring import S... |
def test_all():
'\n Call some tests that were originally in SymPy.\n\n EXAMPLES::\n\n sage: from sage.interfaces.sympy import test_all\n sage: test_all()\n '
def test_basics():
check_expression('x', 'x')
check_expression('x**2', 'x')
check_expression('x**2+y**3'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.