code stringlengths 17 6.64M |
|---|
def dynamic_class(name, bases, cls=None, reduction=None, doccls=None, prepend_cls_bases=True, cache=True):
'\n INPUT:\n\n - ``name`` -- a string\n - ``bases`` -- a tuple of classes\n - ``cls`` -- a class or ``None``\n - ``reduction`` -- a tuple or ``None``\n - ``doccls`` -- a class or ``None``\n... |
@weak_cached_function
def dynamic_class_internal(name, bases, cls=None, reduction=None, doccls=None, prepend_cls_bases=True):
'\n See sage.structure.dynamic_class.dynamic_class? for indirect doctests.\n\n TESTS::\n\n sage: Foo1 = sage.structure.dynamic_class.dynamic_class_internal("Foo", (object,))\n... |
class DynamicMetaclass(type):
'\n A metaclass implementing an appropriate reduce-by-construction method\n '
def _sage_src_lines_(self):
'\n Get the source lines of the dynamic class. This defers to the\n source lines of the ``_doccls`` attribute, which is set when\n the dyn... |
class DynamicClasscallMetaclass(DynamicMetaclass, ClasscallMetaclass):
pass
|
class DynamicInheritComparisonMetaclass(DynamicMetaclass, InheritComparisonMetaclass):
pass
|
class DynamicInheritComparisonClasscallMetaclass(DynamicMetaclass, InheritComparisonClasscallMetaclass):
pass
|
class TestClass():
'\n A class used for checking that introspection works\n '
def bla():
'\n bla ...\n '
pass
|
@richcmp_method
class Factorization(SageObject):
'\n A formal factorization of an object.\n\n EXAMPLES::\n\n sage: N = 2006\n sage: F = N.factor(); F\n 2 * 17 * 59\n sage: F.unit()\n 1\n sage: F = factor(-2006); F\n -1 * 2 * 17 * 59\n sage: F.unit()\n ... |
class IntegerFactorization(Factorization):
'\n A lightweight class for an ``IntegerFactorization`` object,\n inheriting from the more general ``Factorization`` class.\n\n In the ``Factorization`` class the user has to create a list\n containing the factorization data, which is then passed to the\n ... |
class FormalSum(ModuleElement):
'\n A formal sum over a ring.\n '
def __init__(self, x, parent=None, check=True, reduce=True):
"\n INPUT:\n\n - ``x`` -- object\n - ``parent`` -- FormalSums(R) module (default: FormalSums(ZZ))\n - ``check`` -- bool (default: ``True``) ... |
class FormalSums(UniqueRepresentation, Module):
"\n The R-module of finite formal sums with coefficients in some ring R.\n\n EXAMPLES::\n\n sage: FormalSums()\n Abelian Group of all Formal Finite Sums over Integer Ring\n sage: FormalSums(ZZ)\n Abelian Group of all Formal Finite S... |
def multiplicative_iterator(M):
from sage.rings.infinity import infinity
G = M.gens()
if (len(G) == 0):
(yield M(1))
return
stop = [g.multiplicative_order() for g in G]
for i in range(len(stop)):
if (stop[i] is infinity):
raise ArithmeticError(('%s is not finite... |
def abelian_iterator(M):
from sage.rings.infinity import infinity
G = M.gens()
if (len(G) == 0):
(yield M(0))
return
stop = [g.additive_order() for g in G]
for i in range(len(stop)):
if (stop[i] is infinity):
raise ArithmeticError(('%s is not finite.' % M))
... |
class Option():
"\n An option.\n\n Each option for an options class is an instance of this class which\n implements the magic that allows the options to the attributes of the\n options class that can be looked up, set and called.\n\n By way of example, this class implements the following functional... |
class GlobalOptionsMetaMeta(type):
def __call__(self, name, bases, dict):
'\n Called when subclassing an instance of ``self``.\n\n Python translates ``class C(B): ...`` to\n ``meta = type(B); C = meta("C", (B,), ...)``.\n If we want to intercept this call ``meta(...)``, we nee... |
class GlobalOptionsMeta(type, metaclass=GlobalOptionsMetaMeta):
'\n Metaclass for :class:`GlobalOptions`\n\n This class is itself an instance of :class:`GlobalOptionsMetaMeta`,\n which implements the subclass magic.\n '
|
@instancedoc
class GlobalOptions(metaclass=GlobalOptionsMeta):
'\n The :class:`GlobalOptions` class is a generic class for setting and\n accessing global options for Sage objects.\n\n While it is possible to create instances of :class:`GlobalOptions`\n the usual way, the recommended syntax is to subcl... |
class IndexedGenerators():
'nodetex\n Abstract base class for parents whose elements consist of generators\n indexed by an arbitrary set.\n\n Options controlling the printing of elements:\n\n - ``prefix`` -- string, prefix used for printing elements of this\n module (optional, default \'x\'). Wi... |
def split_index_keywords(kwds):
"\n Split the dictionary ``kwds`` into two dictionaries, one containing\n keywords for :class:`IndexedGenerators`, and the other is everything else.\n\n OUTPUT:\n\n The dictionary containing only they keywords\n for :class:`IndexedGenerators`. This modifies the dicti... |
def parse_indices_names(names, index_set, prefix, kwds=None):
"\n Parse the names, index set, and prefix input, along with setting\n default values for keyword arguments ``kwds``.\n\n OUTPUT:\n\n The triple ``(N, I, p)``:\n\n - ``N`` is the tuple of variable names,\n - ``I`` is the index set, an... |
def standardize_names_index_set(names=None, index_set=None, ngens=None):
"\n Standardize the ``names`` and ``index_set`` inputs.\n\n INPUT:\n\n - ``names`` -- (optional) the variable names\n - ``index_set`` -- (optional) the index set\n - ``ngens`` -- (optional) the number of generators\n\n If `... |
class IncreasingArraysPy(IncreasingArrays):
class Element(ClonableArray):
'\n A small class for testing :class:`ClonableArray`: Increasing Lists\n\n TESTS::\n\n sage: from sage.structure.list_clone_timings import IncreasingArraysPy\n sage: TestSuite(IncreasingArraysPy(... |
def add1_internal(bla):
'\n TESTS::\n\n sage: from sage.structure.list_clone_timings import *\n sage: add1_internal(IncreasingArrays()([1,4,5]))\n [2, 5, 6]\n '
blo = bla.__copy__()
lst = blo._get_list()
for i in range(len(blo)):
lst[i] += 1
blo.set_immutable()
... |
def add1_immutable(bla):
'\n TESTS::\n\n sage: from sage.structure.list_clone_timings import *\n sage: add1_immutable(IncreasingArrays()([1,4,5]))\n [2, 5, 6]\n '
lbla = bla[:]
for i in range(len(lbla)):
lbla[i] += 1
return bla.__class__(bla.parent(), lbla)
|
def add1_mutable(bla):
'\n TESTS::\n\n sage: from sage.structure.list_clone_timings import *\n sage: add1_mutable(IncreasingArrays()([1,4,5]))\n [2, 5, 6]\n '
blo = bla.__copy__()
for i in range(len(blo)):
blo[i] += 1
blo.set_immutable()
blo.check()
return bl... |
def add1_with(bla):
'\n TESTS::\n\n sage: from sage.structure.list_clone_timings import *\n sage: add1_with(IncreasingArrays()([1,4,5]))\n [2, 5, 6]\n '
with bla.clone() as blo:
for i in range(len(blo)):
blo[i] += 1
return blo
|
class Nonexact():
'\n A non-exact object with default precision.\n\n INPUT:\n\n - ``prec`` -- a non-negative integer representing the default precision of\n ``self`` (default: ``20``)\n '
def __init__(self, prec=20):
if (prec < 0):
raise ValueError(f'prec (= {prec}) must ... |
def arithmetic(t=None):
'\n Controls the default proof strategy for integer arithmetic algorithms\n (such as primality testing).\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires integer arithmetic operations to (by\n default) return results that are true unco... |
def elliptic_curve(t=None):
'\n Controls the default proof strategy for elliptic curve algorithms.\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires elliptic curve algorithms to (by\n default) return results that are true unconditionally: the\n correctness wil... |
def linear_algebra(t=None):
'\n Controls the default proof strategy for linear algebra algorithms.\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires linear algebra algorithms to (by\n default) return results that are true unconditionally: the\n correctness wil... |
def number_field(t=None):
'\n Controls the default proof strategy for number field algorithms.\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires number field algorithms to (by default)\n return results that are true unconditionally: the correctness will\n not ... |
def polynomial(t=None):
'\n Controls the default proof strategy for polynomial algorithms.\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires polynomial algorithms to (by default)\n return results that are true unconditionally: the correctness will\n not depend... |
def all(t=None):
"\n Controls the default proof strategy throughout Sage.\n\n INPUT:\n\n t -- boolean or ``None``\n\n OUTPUT:\n\n If t is ``True``, requires Sage algorithms to (by default) return\n results that are true unconditionally: the correctness will not\n depend on an algorithm with a... |
class _ProofPref(SageObject):
'\n An object that holds global proof preferences. For now these are merely True/False flags for various parts of Sage that use probabilistic algorithms.\n A True flag means that the subsystem (such as linear algebra or number fields) should return results that are true uncond... |
def get_flag(t=None, subsystem=None):
'\n Used for easily determining the correct proof flag to use.\n\n EXAMPLES::\n\n sage: from sage.structure.proof.proof import get_flag\n sage: get_flag(False)\n False\n sage: get_flag(True)\n True\n sage: get_flag()\n Tr... |
class WithProof():
'\n Use WithProof to temporarily set the value of one of the proof\n systems for a block of code, with a guarantee that it will be set\n back to how it was before after the block is done, even if there is an error.\n\n EXAMPLES:\n\n This would hang "forever" if attempted with ``p... |
class SageObjectTests():
@pytest.fixture
def sage_object(self, *args, **kwargs) -> SageObject:
raise NotImplementedError
def test_sage_unittest_testsuite(self, sage_object: SageObject):
'\n Subclasses should override this method if they need to skip some tests.\n '
... |
def Sequence(x, universe=None, check=True, immutable=False, cr=False, cr_str=None, use_sage_types=False):
'\n A mutable list of elements with a common guaranteed universe,\n which can be set immutable.\n\n A universe is either an object that supports coercion (e.g., a\n parent), or a category.\n\n ... |
class Sequence_generic(sage.structure.sage_object.SageObject, list):
'\n A mutable list of elements with a common guaranteed universe,\n which can be set immutable.\n\n A universe is either an object that supports coercion (e.g., a parent),\n or a category.\n\n INPUT:\n\n - ``x`` - a list or tup... |
class SetFactory(UniqueRepresentation, SageObject):
'\n This class is currently just a stub that we will be using to add\n more structures on factories.\n\n TESTS::\n\n sage: from sage.structure.set_factories import SetFactory\n sage: S = SetFactory()\n sage: S.__call__("foo")\n ... |
class SetFactoryPolicy(UniqueRepresentation, SageObject):
'\n Abstract base class for policies.\n\n A policy is a device which is passed to a parent inheriting from\n :class:`ParentWithSetFactory` in order to set-up the element\n construction framework.\n\n INPUT:\n\n - ``factory`` -- a :class:`... |
class SelfParentPolicy(SetFactoryPolicy):
'\n Policy where each parent is a standard parent.\n\n INPUT:\n\n - ``factory`` -- an instance of :class:`SetFactory`\n - ``Element`` -- a subclass of :class:`~.element.Element`\n\n Given a factory ``F`` and a class ``E``, returns a policy for\n parent `... |
class TopMostParentPolicy(SetFactoryPolicy):
"\n Policy where the parent of the elements is the topmost parent.\n\n INPUT:\n\n - ``factory`` -- an instance of :class:`SetFactory`\n - ``top_constraints`` -- the empty set of constraints.\n - ``Element`` -- a subclass of :class:`~.element.Element`\n\n... |
class FacadeParentPolicy(SetFactoryPolicy):
'\n Policy for facade parent.\n\n INPUT:\n\n - ``factory`` -- an instance of :class:`SetFactory`\n - ``parent`` -- an instance of :class:`Parent`\n\n Given a factory ``F`` and a class ``E``, returns a policy for\n parent ``P`` creating elements as if t... |
class BareFunctionPolicy(SetFactoryPolicy):
"\n Policy where element are constructed using a bare function.\n\n INPUT:\n\n - ``factory`` -- an instance of :class:`SetFactory`\n - ``constructor`` -- a function\n\n Given a factory ``F`` and a function ``c``, returns a policy for\n parent ``P`` cre... |
class ParentWithSetFactory(Parent):
'\n Abstract class for parent belonging to a set factory.\n\n INPUT:\n\n - ``constraints`` -- a set of constraints\n - ``policy`` -- the policy for element construction\n - ``category`` -- the category of the parent (default to ``None``)\n\n Depending on the c... |
class XYPairsFactory(SetFactory):
'\n An example of set factory, for sets of pairs of integers.\n\n .. SEEALSO::\n\n :mod:`.set_factories` for an introduction to set factories.\n '
def __call__(self, x=None, y=None, policy=None):
'\n Construct the subset from constraints.\n\n ... |
class XYPair(ElementWrapper):
'\n A class for Elements `(x,y)` with `x` and `y` in `\\{0,1,2,3,4\\}`.\n\n EXAMPLES::\n\n sage: from sage.structure.set_factories_example import XYPair\n sage: p = XYPair(Parent(), (0,1)); p\n (0, 1)\n sage: p = XYPair(Parent(), (0,8))\n Trac... |
class AllPairs(ParentWithSetFactory, DisjointUnionEnumeratedSets):
'\n This parent shows how one can use set factories together with\n :class:`DisjointUnionEnumeratedSets`.\n\n It is constructed as the disjoint union\n (:class:`DisjointUnionEnumeratedSets`) of :class:`Pairs_Y` parents:\n\n .. MATH:... |
class PairsX_(ParentWithSetFactory, UniqueRepresentation):
'\n The set of pairs `(x, 0), (x, 1), ..., (x, 4)`.\n\n TESTS::\n\n sage: from sage.structure.set_factories_example import XYPairs\n sage: P = XYPairs(0); P.list()\n [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]\n '
def __ini... |
class Pairs_Y(ParentWithSetFactory, DisjointUnionEnumeratedSets):
'\n The set of pairs `(0, y), (1, y), ..., (4, y)`.\n\n It is constructed as the disjoint union\n (:class:`DisjointUnionEnumeratedSets`) of :class:`SingletonPair` parents:\n\n .. MATH::\n\n S^y := \\bigcup_{i = 0,1,..., 4} S_i^y\... |
class SingletonPair(ParentWithSetFactory, UniqueRepresentation):
'\n TESTS::\n\n sage: from sage.structure.set_factories_example import XYPairs\n sage: P = XYPairs(0,1); P.list()\n [(0, 1)]\n '
def __init__(self, x, y, policy):
'\n TESTS::\n\n sage: from s... |
class SupportView(MappingView, Sequence, Set):
"\n Dynamic view of the set of keys of a dictionary that are associated with nonzero values\n\n It behaves like the objects returned by the :meth:`keys`, :meth:`values`,\n :meth:`items` of a dictionary (or other :class:`collections.abc.Mapping`\n classes)... |
class A():
pass
|
class UniqueFactoryTester(UniqueFactory):
def create_key(self, *args, **kwds):
"\n EXAMPLES::\n\n sage: from sage.structure.test_factory import UniqueFactoryTester\n sage: test_factory = UniqueFactoryTester('foo')\n sage: test_factory.create_key(1, 2, 3)\n ... |
class CachedRepresentation(metaclass=ClasscallMetaclass):
'\n Classes derived from CachedRepresentation inherit a weak cache for their\n instances.\n\n .. NOTE::\n\n If this class is used as a base class, then instances are (weakly)\n cached, according to the arguments used to create the in... |
def unreduce(cls, args, keywords):
'\n Calls a class on the given arguments::\n\n sage: sage.structure.unique_representation.unreduce(Integer, (1,), {})\n 1\n\n .. TODO::\n\n should reuse something preexisting ...\n\n '
return cls(*args, **keywords)
|
class UniqueRepresentation(CachedRepresentation, WithEqualityById):
'\n Classes derived from UniqueRepresentation inherit a unique\n representation behavior for their instances.\n\n .. SEEALSO::\n\n :mod:`~sage.structure.unique_representation`\n\n EXAMPLES:\n\n The short story: to construct ... |
class GenericDeclaration(UniqueRepresentation):
'\n This class represents generic assumptions, such as a variable being\n an integer or a function being increasing. It passes such\n information to Maxima\'s declare (wrapped in a context so it is able\n to forget) and to Pynac.\n\n INPUT:\n\n - ... |
def preprocess_assumptions(args):
"\n Turn a list of the form ``(var1, var2, ..., 'property')`` into a\n sequence of declarations ``(var1 is property), (var2 is property),\n ...``\n\n EXAMPLES::\n\n sage: from sage.symbolic.assumptions import preprocess_assumptions\n sage: preprocess_ass... |
def assume(*args):
'\n Make the given assumptions.\n\n INPUT:\n\n - ``*args`` -- a variable-length sequence of assumptions, each\n consisting of:\n\n - any number of symbolic inequalities, like ``0 < x, x < 1``\n\n - a subsequence of variable names, followed by some property that\n ... |
def forget(*args):
"\n Forget the given assumption, or call with no arguments to forget\n all assumptions.\n\n Here an assumption is some sort of symbolic constraint.\n\n INPUT:\n\n - ``*args`` -- assumptions (default: forget all\n assumptions)\n\n EXAMPLES:\n\n We define and forget mu... |
def assumptions(*args):
"\n List all current symbolic assumptions.\n\n INPUT:\n\n - ``args`` -- list of variables which can be empty.\n\n OUTPUT:\n\n - list of assumptions on variables. If args is empty it returns all\n assumptions\n\n EXAMPLES::\n\n sage: var('x, y, z, w')\n ... |
def _forget_all():
"\n Forget all symbolic assumptions.\n\n This is called by ``forget()``.\n\n EXAMPLES::\n\n sage: forget()\n sage: var('x,y')\n (x, y)\n sage: assume(x > 0, y < 0)\n sage: bool(x*y < 0) # means definitely true\n True\n sage: bool(x*... |
class assuming():
'\n Temporarily modify assumptions.\n\n Create a context manager in which temporary assumptions are added\n (or substituted) to the current assumptions set.\n\n The set of possible assumptions and declarations is the same as for\n :func:`assume`.\n\n This can be useful in inte... |
class CallableSymbolicExpressionFunctor(ConstructionFunctor):
def __init__(self, arguments):
"\n A functor which produces a CallableSymbolicExpressionRing from\n the SymbolicRing.\n\n EXAMPLES::\n\n sage: from sage.symbolic.callable import CallableSymbolicExpressionFunctor... |
class CallableSymbolicExpressionRing_class(SymbolicRing, sage.rings.abc.CallableSymbolicExpressionRing):
def __init__(self, arguments):
"\n EXAMPLES:\n\n We verify that coercion works in the case where ``x`` is not an\n instance of SymbolicExpression, but its parent is still the\n ... |
class CallableSymbolicExpressionRingFactory(UniqueFactory):
def create_key(self, args, check=True):
"\n EXAMPLES::\n\n sage: x,y = var('x,y')\n sage: CallableSymbolicExpressionRing.create_key((x,y))\n (x, y)\n "
if check:
from sage.struct... |
def string_length(expr):
'\n Returns the length of ``expr`` after converting it to a string.\n\n INPUT:\n\n - ``expr`` -- the expression whose complexity we want to measure.\n\n OUTPUT:\n\n A real number representing the complexity of ``expr``.\n\n RATIONALE:\n\n If the expression is longer o... |
def unpickle_Constant(class_name, name, conversions, latex, mathml, domain):
"\n EXAMPLES::\n\n sage: from sage.symbolic.constants import unpickle_Constant\n sage: a = unpickle_Constant('Constant', 'a', {}, 'aa', '', 'positive')\n sage: a.domain()\n 'positive'\n sage: latex(a... |
@richcmp_method
class Constant():
def __init__(self, name, conversions=None, latex=None, mathml='', domain='complex'):
"\n EXAMPLES::\n\n sage: from sage.symbolic.constants import Constant\n sage: p = Constant('p')\n sage: loads(dumps(p))\n p\n "
... |
class Pi(Constant):
def __init__(self, name='pi'):
"\n TESTS::\n\n sage: pi._latex_()\n '\\\\pi'\n sage: latex(pi)\n \\pi\n sage: mathml(pi)\n <mi>π</mi>\n "
conversions = dict(axiom='%pi', fricas='%pi', maxima='%p... |
class NotANumber(Constant):
'\n Not a Number\n '
def __init__(self, name='NaN'):
'\n EXAMPLES::\n\n sage: loads(dumps(NaN))\n NaN\n '
conversions = dict(matlab='NaN')
Constant.__init__(self, name, conversions=conversions)
def __float__(se... |
class GoldenRatio(Constant):
'\n The number (1+sqrt(5))/2\n\n EXAMPLES::\n\n sage: gr = golden_ratio\n sage: RR(gr)\n 1.61803398874989\n sage: R = RealField(200)\n sage: R(gr)\n 1.6180339887498948482045868343656381177203091798057628621354\n sage: grm = maxima... |
class Log2(Constant):
'\n The natural logarithm of the real number 2.\n\n EXAMPLES::\n\n sage: log2\n log2\n sage: float(log2)\n 0.6931471805599453\n sage: RR(log2)\n 0.693147180559945\n sage: R = RealField(200); R\n Real Field with 200 bits of precisi... |
class EulerGamma(Constant):
'\n The limiting difference between the harmonic series and the natural\n logarithm.\n\n EXAMPLES::\n\n sage: R = RealField()\n sage: R(euler_gamma)\n 0.577215664901533\n sage: R = RealField(200); R\n Real Field with 200 bits of precision\n ... |
class Catalan(Constant):
'\n A number appearing in combinatorics defined as the Dirichlet beta\n function evaluated at the number 2.\n\n EXAMPLES::\n\n sage: catalan^2 + mertens\n mertens + catalan^2\n '
def __init__(self, name='catalan'):
'\n EXAMPLES::\n\n ... |
class Khinchin(Constant):
'\n The geometric mean of the continued fraction expansion of any\n (almost any) real number.\n\n EXAMPLES::\n\n sage: float(khinchin)\n 2.6854520010653062\n sage: khinchin.n(digits=60)\n 2.68545200106530644530971483548179569382038229399446295305115\n... |
class TwinPrime(Constant):
'\n The Twin Primes constant is defined as\n `\\prod 1 - 1/(p-1)^2` for primes `p > 2`.\n\n EXAMPLES::\n\n sage: float(twinprime)\n 0.6601618158468696\n sage: twinprime.n(digits=60)\n 0.660161815846869573927812110014555778432623360284733413319448\n\n... |
class Mertens(Constant):
"\n The Mertens constant is related to the Twin Primes constant and\n appears in Mertens' second theorem.\n\n EXAMPLES::\n\n sage: float(mertens)\n 0.26149721284764277\n sage: mertens.n(digits=60)\n 0.261497212847642783755426838608695859051566648261199... |
class Glaisher(Constant):
"\n The Glaisher-Kinkelin constant `A = \\exp(\\frac{1}{12}-\\zeta'(-1))`.\n\n EXAMPLES::\n\n sage: float(glaisher)\n 1.2824271291006226\n sage: glaisher.n(digits=60)\n 1.28242712910062263687534256886979172776768892732500119206374\n sage: a = glai... |
class AlgebraicConverter(Converter):
def __init__(self, field):
"\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import AlgebraicConverter\n sage: a = AlgebraicConverter(QQbar)\n sage: a.field\n Algebraic Field\n sage: a.reci... |
def algebraic(ex, field):
"\n Returns the symbolic expression *ex* as a element of the algebraic\n field *field*.\n\n EXAMPLES::\n\n sage: a = SR(5/6)\n sage: AA(a)\n 5/6\n sage: type(AA(a))\n <class 'sage.rings.qqbar.AlgebraicReal'>\n sage: QQbar(a)\n 5/6... |
class SympyConverter(Converter):
"\n Converts any expression to SymPy.\n\n EXAMPLES::\n\n sage: import sympy\n sage: var('x,y')\n (x, y)\n sage: f = exp(x^2) - arcsin(pi+x)/y\n sage: f._sympy_()\n exp(x**2) - asin(x + pi)/y\n sage: _._sage_()\n -arcsin... |
class FakeExpression():
"\n Pynac represents `x/y` as `xy^{-1}`. Often, tree-walkers would prefer\n to see divisions instead of multiplications and negative exponents.\n To allow for this (since Pynac internally doesn't have division at all),\n there is a possibility to pass use_fake_div=True; this w... |
class Converter():
def __init__(self, use_fake_div=False):
'\n If use_fake_div is set to True, then the converter will try to\n replace expressions whose operator is operator.mul with the\n corresponding expression whose operator is operator.truediv.\n\n EXAMPLES::\n\n ... |
class InterfaceInit(Converter):
def __init__(self, interface):
"\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import InterfaceInit\n sage: m = InterfaceInit(maxima)\n sage: a = pi + 2\n sage: m(a)\n '(%pi)+(2)'\n ... |
class FriCASConverter(InterfaceInit):
"\n Converts any expression to FriCAS.\n\n EXAMPLES::\n\n sage: var('x,y')\n (x, y)\n sage: f = exp(x^2) - arcsin(pi+x)/y\n sage: f._fricas_() # optional - fricas\n 2\n ... |
class PolynomialConverter(Converter):
def __init__(self, ex, base_ring=None, ring=None):
"\n A converter from symbolic expressions to polynomials.\n\n See :func:`polynomial` for details.\n\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import PolynomialCo... |
def polynomial(ex, base_ring=None, ring=None):
"\n Return a polynomial from the symbolic expression ``ex``.\n\n INPUT:\n\n - ``ex`` -- a symbolic expression\n\n - ``base_ring``, ``ring`` -- Either a\n ``base_ring`` or a polynomial ``ring`` can be\n specified for the parent of result.\n ... |
class LaurentPolynomialConverter(PolynomialConverter):
def __init__(self, ex, base_ring=None, ring=None):
"\n A converter from symbolic expressions to Laurent polynomials.\n\n See :func:`laurent_polynomial` for details.\n\n TESTS::\n\n sage: from sage.symbolic.expression_c... |
def laurent_polynomial(ex, base_ring=None, ring=None):
"\n Return a Laurent polynomial from the symbolic expression ``ex``.\n\n INPUT:\n\n - ``ex`` -- a symbolic expression\n\n - ``base_ring``, ``ring`` -- Either a\n ``base_ring`` or a Laurent polynomial ``ring`` can be\n specified for the p... |
class FastCallableConverter(Converter):
def __init__(self, ex, etb):
"\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import FastCallableConverter\n sage: from sage.ext.fast_callable import ExpressionTreeBuilder\n sage: etb = ExpressionTreeBuilder... |
def fast_callable(ex, etb):
"\n Given an ExpressionTreeBuilder *etb*, return an Expression representing\n the symbolic expression *ex*.\n\n EXAMPLES::\n\n sage: from sage.ext.fast_callable import ExpressionTreeBuilder\n sage: etb = ExpressionTreeBuilder(vars=['x','y'])\n sage: x,y = ... |
class RingConverter(Converter):
def __init__(self, R, subs_dict=None):
'\n A class to convert expressions to other rings.\n\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import RingConverter\n sage: R = RingConverter(RIF, subs_dict={x:2})\n ... |
class ExpressionTreeWalker(Converter):
def __init__(self, ex):
'\n A class that walks the tree. Mainly for subclassing.\n\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import ExpressionTreeWalker\n sage: from sage.symbolic.random_tests import random_... |
class SubstituteFunction(ExpressionTreeWalker):
def __init__(self, ex, *args):
"\n A class that walks the tree and replaces occurrences of a\n function with another.\n\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import SubstituteFunction\n s... |
class Exponentialize(ExpressionTreeWalker):
from sage.functions.hyperbolic import sinh, cosh, sech, csch, tanh, coth
from sage.functions.log import exp
from sage.functions.trig import sin, cos, sec, csc, tan, cot
from sage.symbolic.constants import e, I
from sage.rings.integer import Integer
f... |
class DeMoivre(ExpressionTreeWalker):
def __init__(self, ex, force=False):
'\n A class that walks a symbolic expression tree and replaces\n occurences of complex exponentials (optionally, all\n exponentials) by their respective trigonometric expressions.\n\n INPUT:\n\n ... |
class HoldRemover(ExpressionTreeWalker):
def __init__(self, ex, exclude=None):
'\n A class that walks the tree and evaluates every operator\n that is not in a given list of exceptions.\n\n EXAMPLES::\n\n sage: from sage.symbolic.expression_conversions import HoldRemover\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.