hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
8ae1a9925ba1510614913601785739cc9bc8a500f78007849fee7171baf67445 | """Useful utility decorators. """
import sys
import types
import inspect
from functools import wraps, update_wrapper
from sympy.testing.runtests import DependencyError, SymPyDocTests, PyTestReporter
from sympy.utilities.exceptions import SymPyDeprecationWarning
def threaded_factory(func, use_add):
"""A factory f... |
28dd3b7dd2fcd3cca849bea5c5af9088ee59968ff8cde73e38b8aeff837e741e | """
The objects in this module allow the usage of the MatchPy pattern matching
library on SymPy expressions.
"""
import re
from typing import List, Callable
from sympy.core.sympify import _sympify
from sympy.external import import_module
from sympy.functions import (log, sin, cos, tan, cot, csc, sec, erf, gamma, upper... |
646394526c0908d4611d56634c5e23eb95a343a554a02782d44f03923af2534d | from functools import wraps
def recurrence_memo(initial):
"""
Memo decorator for sequences defined by recurrence
See usage examples e.g. in the specfun/combinatorial module
"""
cache = initial
def decorator(f):
@wraps(f)
def g(n):
L = len(cache)
if n <... |
b22af1ce293daf5c843d796fa5b62789a9d26dc231dda4c5dc7134f46b9a3e38 | from collections import defaultdict, OrderedDict
from itertools import (
combinations, combinations_with_replacement, permutations,
product
)
# For backwards compatibility
from itertools import product as cartes # noqa: F401
from operator import gt
# this is the logical location of these functions
# from sym... |
defdba64aefd2e264ce79b2a86f81ce908e541050e503ab3567bff544a10f045 | """Miscellaneous stuff that doesn't really fit anywhere else."""
from typing import List
import operator
import sys
import os
import re as _re
import struct
from textwrap import fill, dedent
class Undecidable(ValueError):
# an error to be raised when a decision cannot be made definitively
# where a definiti... |
74aeae7aa57a38e5e0d2a63d2fe8283a06d06aba9547280860ae454064c13d1f | """A module providing information about the necessity of brackets"""
# Default precedence values for some basic types
PRECEDENCE = {
"Lambda": 1,
"Xor": 10,
"Or": 20,
"And": 30,
"Relational": 35,
"Add": 40,
"Mul": 50,
"Pow": 60,
"Func": 70,
"Not": 100,
"Atom": 1000,
"Bi... |
f490577b52730dd2e4afc56ebafe58a8447aba6fbc7581cad5451250eb03a531 | from sympy.core import S
from .pycode import PythonCodePrinter, _known_functions_math, _print_known_const, _print_known_func, _unpack_integral_limits
from .codeprinter import CodePrinter
_not_in_numpy = 'erf erfc factorial gamma loggamma'.split()
_in_numpy = [(k, v) for k, v in _known_functions_math.items() if k not ... |
8ea3b53db889260ddf4d1b828e9a98d7a2db895d760d5fd345d867a95c2b0d72 | """
Python code printers
This module contains Python code printers for plain Python as well as NumPy & SciPy enabled code.
"""
from collections import defaultdict
from itertools import chain
from sympy.core import S
from .precedence import precedence
from .codeprinter import CodePrinter
_kw_py2and3 = {
'and', 'as... |
e72cf5593ed3614692c81a0ea593a988c51464c6d98a99caa89ab8e3233a6976 | """
A Printer for generating readable representation of most SymPy classes.
"""
from typing import Any, Dict as tDict
from sympy.core import S, Rational, Pow, Basic, Mul, Number
from sympy.core.mul import _keep_coeff
from sympy.core.relational import Relational
from sympy.core.sorting import default_sort_key
from sym... |
ab5f4b5f8061cb3afc618b7dbbc5890342c50dd34cb5f1c37043f2d1b38987b3 | """
Rust code printer
The `RustCodePrinter` converts SymPy expressions into Rust expressions.
A complete code generator, which uses `rust_code` extensively, can be found
in `sympy.utilities.codegen`. The `codegen` module can be used to generate
complete source code files.
"""
# Possible Improvement
#
# * make sure ... |
c04552e8d4b0465b757f9526d766d56aa26d4edb4964cab37b3a96bb261803e2 | """
C++ code printer
"""
from itertools import chain
from sympy.codegen.ast import Type, none
from .c import C89CodePrinter, C99CodePrinter
# These are defined in the other file so we can avoid importing sympy.codegen
# from the top-level 'import sympy'. Export them here as well.
from sympy.printing.codeprinter impor... |
5f257e0f9b307fc886425eaa478332b665fdc682961fec1b3a524ad024da8928 | '''
Use llvmlite to create executable functions from SymPy expressions
This module requires llvmlite (https://github.com/numba/llvmlite).
'''
import ctypes
from sympy.external import import_module
from sympy.printing.printer import Printer
from sympy.core.singleton import S
from sympy.tensor.indexed import IndexedBa... |
93a6115877ef6cb1c9a75b8a8105fec9288e5d2b171fc409c42f5fca66267123 | """
A few practical conventions common to all printers.
"""
import re
from collections.abc import Iterable
from sympy.core.function import Derivative
_name_with_digits_p = re.compile(r'^([^\W\d_]+)(\d+)$', re.U)
def split_super_sub(text):
"""Split a symbol name into a name, superscripts and subscripts
The... |
840bc07cded01a28e5e00434a9d3ef570727c3ecaf7069a36ab44dbfe9044b5f | """
A Printer which converts an expression into its LaTeX equivalent.
"""
from typing import Any, Dict as tDict
import itertools
from sympy.core import Add, Float, Mod, Mul, Number, S, Symbol
from sympy.core.alphabets import greeks
from sympy.core.containers import Tuple
from sympy.core.function import AppliedUndef,... |
83c403d0b20559fe6512760f9a7cb616bd1e81d858cc9e8d7a10d460e1c81b83 | """Printing subsystem driver
SymPy's printing system works the following way: Any expression can be
passed to a designated Printer who then is responsible to return an
adequate representation of that expression.
**The basic concept is the following:**
1. Let the object print itself if it knows how.
2. Take the bes... |
c71971e4e98a7c94268de966667c2ed406e0c6fe26ae9d7f573bf09d2c38192e | from sympy.core.containers import Tuple
from sympy.core.singleton import S
from sympy.core.symbol import Symbol
from sympy.core.sympify import SympifyError
from types import FunctionType
class TableForm:
r"""
Create a nice table representation of data.
Examples
========
>>> from sympy import Ta... |
218f1cda7a15d0e00812e7d24a8eedf8c67be2a1c23bf1a1450747345b8f1837 | """
C code printer
The C89CodePrinter & C99CodePrinter converts single SymPy expressions into
single C expressions, using the functions defined in math.h where possible.
A complete code generator, which uses ccode extensively, can be found in
sympy.utilities.codegen. The codegen module can be used to generate complet... |
651b94a40d8e1db5a185ead67049913e7748a43bec5f1c6d6c13e087fdc817d2 | from .pycode import (
PythonCodePrinter,
MpmathPrinter,
)
from .numpy import NumPyPrinter # NumPyPrinter is imported for backward compatibility
from sympy.core.sorting import default_sort_key
__all__ = [
'PythonCodePrinter',
'MpmathPrinter', # MpmathPrinter is published for backward compatibility
... |
24656e02fdd960eeb953a58cf1c8df11a32428fb97b38e094d9e54eca37a224e | """
Mathematica code printer
"""
from typing import Any, Dict as tDict, Set as tSet, Tuple as tTuple
from sympy.core import Basic, Expr, Float
from sympy.core.sorting import default_sort_key
from sympy.printing.codeprinter import CodePrinter
from sympy.printing.precedence import precedence
# Used in MCodePrinter._p... |
3a7a3e803e4cb5ef5b97a971dedab3706dfa19dc05243d9fd08aecd0d15b7699 | """
Fortran code printer
The FCodePrinter converts single SymPy expressions into single Fortran
expressions, using the functions defined in the Fortran 77 standard where
possible. Some useful pointers to Fortran can be found on wikipedia:
https://en.wikipedia.org/wiki/Fortran
Most of the code below is based on the "... |
73e0936e2a393c7ee708e87ba9a343ce0021744c8ce974ab9142b51f7011487e | """
A MathML printer.
"""
from typing import Any, Dict as tDict
from sympy.core.mul import Mul
from sympy.core.singleton import S
from sympy.core.sorting import default_sort_key
from sympy.core.sympify import sympify
from sympy.printing.conventions import split_super_sub, requires_partial
from sympy.printing.preceden... |
ace7f8954d3a50f22798b70119b1f130bc6f8fba328e45317b145341cfeec653 | """
R code printer
The RCodePrinter converts single SymPy expressions into single R expressions,
using the functions defined in math.h where possible.
"""
from typing import Any, Dict as tDict
from sympy.printing.codeprinter import CodePrinter
from sympy.printing.precedence import precedence, PRECEDENCE
from symp... |
d628f2a923ff35dae73aa86820ab62a0a29cf834809289469ae38c3e7b7168d1 | """
Octave (and Matlab) code printer
The `OctaveCodePrinter` converts SymPy expressions into Octave expressions.
It uses a subset of the Octave language for Matlab compatibility.
A complete code generator, which uses `octave_code` extensively, can be found
in `sympy.utilities.codegen`. The `codegen` module can be us... |
e39f1836f38ea744657f45d042987fd528d876f4f087c37aa846545659e44018 | from typing import Any, Dict as tDict, Set as tSet, Tuple as tTuple
from functools import wraps
from sympy.core import Add, Expr, Mul, Pow, S, sympify, Float
from sympy.core.basic import Basic
from sympy.core.expr import UnevaluatedExpr
from sympy.core.function import Lambda
from sympy.core.mul import _keep_coeff
fro... |
a41b693eb00eea248e59a9c6894a1bfff831cd59b95ef822ddbf9080c3ed5fe9 | import keyword as kw
import sympy
from .repr import ReprPrinter
from .str import StrPrinter
# A list of classes that should be printed using StrPrinter
STRPRINT = ("Add", "Infinity", "Integer", "Mul", "NegativeInfinity",
"Pow", "Zero")
class PythonPrinter(ReprPrinter, StrPrinter):
"""A printer which ... |
d063f5541eb8cf1fa53f64ba7fffb847a3d64bd4c05ac8530b04c057aa93e475 | """
Maple code printer
The MapleCodePrinter converts single SymPy expressions into single
Maple expressions, using the functions defined in the Maple objects where possible.
FIXME: This module is still under actively developed. Some functions may be not completed.
"""
from sympy.core import S
from sympy.core.number... |
f274399b300bd62730a02816335ee2092769df54d5ddcbc523b0e38ca768c8ca | from typing import Any, Dict as tDict
from sympy.external import import_module
from sympy.printing.printer import Printer
from sympy.utilities.iterables import is_sequence
import sympy
from functools import partial
aesara = import_module('aesara')
if aesara:
aes = aesara.scalar
aet = aesara.tensor
from ... |
7b5e0f0f689ad34d89bdcb474a82e0f0b338d69ac27688b13595ad934795b657 | from sympy.external.importtools import version_tuple
from collections.abc import Iterable
from sympy.core.mul import Mul
from sympy.core.singleton import S
from sympy.codegen.cfunctions import Sqrt
from sympy.external import import_module
from sympy.printing.precedence import PRECEDENCE
from sympy.printing.pycode impo... |
d7b2dee321783a7f8cbaf1012a74666f9ca7ab9f67f4c7a81c750a39a7c65a17 | """
Javascript code printer
The JavascriptCodePrinter converts single SymPy expressions into single
Javascript expressions, using the functions defined in the Javascript
Math object where possible.
"""
from typing import Any, Dict as tDict
from sympy.core import S
from sympy.printing.codeprinter import CodePrinter
... |
9c33a48fe58a49702d01f572c7b0ff10698bd331c8d1faf9c4a55193a0ea02f4 | """
A Printer for generating executable code.
The most important function here is srepr that returns a string so that the
relation eval(srepr(expr))=expr holds in an appropriate environment.
"""
from typing import Any, Dict as tDict
from sympy.core.function import AppliedUndef
from sympy.core.mul import Mul
from mpm... |
6e4c595fd90bd6899b1d2f63b21a931b6412fdecc7f245dd257477aae0f63fb8 | """
Julia code printer
The `JuliaCodePrinter` converts SymPy expressions into Julia expressions.
A complete code generator, which uses `julia_code` extensively, can be found
in `sympy.utilities.codegen`. The `codegen` module can be used to generate
complete source code files.
"""
from typing import Any, Dict as tD... |
de8dbad84441c3ff6bd78d8b65215744b46a43300cd7862f68695594389d8de2 | from typing import Set as tSet
from sympy.core import Basic, S
from sympy.core.function import Lambda
from sympy.printing.codeprinter import CodePrinter
from sympy.printing.precedence import precedence
from functools import reduce
known_functions = {
'Abs': 'abs',
'sin': 'sin',
'cos': 'cos',
'tan': 't... |
04adf461f853a495a66b26d014c63c8a5253f818425a88f1d3532958d98ad85f | from typing import Any, Dict as tDict
from sympy.external import import_module
from sympy.printing.printer import Printer
from sympy.utilities.iterables import is_sequence
import sympy
from functools import partial
from sympy.utilities.decorator import doctest_depends_on
from sympy.utilities.exceptions import SymPyDe... |
cddecc8d3a810ea92d79c2dcc0ec8f88a85a4fd44d011acd1f79e6369639200b | """Integration method that emulates by-hand techniques.
This module also provides functionality to get the steps used to evaluate a
particular integral, in the ``integral_steps`` function. This will return
nested namedtuples representing the integration rules used. The
``manualintegrate`` function computes the integra... |
ca4c4d09882ec35fcd70a933b3cf3a6b7aeeff4936cdd7f3b02911a6db6cc428 | from sympy.functions import SingularityFunction, DiracDelta
from sympy.core import sympify
from sympy.integrals import integrate
def singularityintegrate(f, x):
"""
This function handles the indefinite integrations of Singularity functions.
The ``integrate`` function calls this function internally wheneve... |
49379a387bbfa2c1471ea72553fdaed20e9ed298db7a0aa67e7fafbfad627eb8 | """ Integral Transforms """
from functools import reduce, wraps
from itertools import repeat
from sympy.core import S, pi
from sympy.core.add import Add
from sympy.core.function import (AppliedUndef, count_ops, expand,
expand_complex, expand_mul, Function, Lambda)
from sympy.core.mul i... |
699af6427ea2fa0bc5187ff91e5fd2467dbe05df527f8cd0770a3d5462d278d6 | """Integration functions that integrate a SymPy expression.
Examples
========
>>> from sympy import integrate, sin
>>> from sympy.abc import x
>>> integrate(1/x,x)
log(x)
>>> integrate(sin(x),x)
-cos(x)
"""
from .integrals import integrate, Integral, line_integrate
from .transforms imp... |
5c3a42662c95b84ea56879ece615a6532434351376084ed32e74d6c622cc1521 | """
Module to implement integration of uni/bivariate polynomials over
2D Polytopes and uni/bi/trivariate polynomials over 3D Polytopes.
Uses evaluation techniques as described in Chin et al. (2015) [1].
References
===========
.. [1] Chin, Eric B., Jean B. Lasserre, and N. Sukumar. "Numerical integration
of homogene... |
849794a555c0e0f409e0e84dfe52752743ca4effbf765fc690e1fee2ba0709e6 | from typing import Tuple as tTuple
from sympy.concrete.expr_with_limits import AddWithLimits
from sympy.core.add import Add
from sympy.core.basic import Basic
from sympy.core.containers import Tuple
from sympy.core.expr import Expr
from sympy.core.exprtools import factor_terms
from sympy.core.function import diff
from... |
866b838215ee7a2a99011e56bd81ea2999f54bf470bd4437e4887a7cb2edf009 | from typing import Dict as tDict, List
from itertools import permutations
from functools import reduce
from sympy.core.add import Add
from sympy.core.basic import Basic
from sympy.core.mul import Mul
from sympy.core.symbol import Wild, Dummy
from sympy.core.basic import sympify
from sympy.core.numbers import Rational... |
02e88f0ea3f66b00b8525589aec7cd0a7d65dce010b9997ae1623e944d8ce43b | """
Algorithms for solving the Risch differential equation.
Given a differential field K of characteristic 0 that is a simple
monomial extension of a base field k and f, g in K, the Risch
Differential Equation problem is to decide if there exist y in K such
that Dy + f*y == g and to find one if there are some. If t i... |
02b12c0f8a1934e09255ba3299d9329caf63b8404d5128e1b9d6b7f0f1e51e6e | """ This module cooks up a docstring when imported. Its only purpose is to
be displayed in the sphinx documentation. """
from typing import Any, Dict as tDict, List, Tuple as tTuple, Type
from sympy.integrals.meijerint import _create_lookup_table
from sympy.core.add import Add
from sympy.core.relational import E... |
a32aed303ecd3e256033833d197a389193787576cdbb2e9d39e1238272882566 | """
The Risch Algorithm for transcendental function integration.
The core algorithms for the Risch algorithm are here. The subproblem
algorithms are in the rde.py and prde.py files for the Risch
Differential Equation solver and the parametric problems solvers,
respectively. All important information concerning the d... |
403d89c60d73ca35e2a31e28c5a4b0f3cfbcfb9948ed42e667deb631e705f473 | """This module implements tools for integrating rational functions. """
from sympy.core.function import Lambda
from sympy.core.numbers import I
from sympy.core.singleton import S
from sympy.core.symbol import (Dummy, Symbol, symbols)
from sympy.functions.elementary.exponential import log
from sympy.functions.elementar... |
38a51af431c45bf5deb5d70502040374b9afd508fa89acfa24b8d93c52d3a222 | from sympy.core.mul import Mul
from sympy.core.singleton import S
from sympy.core.sorting import default_sort_key
from sympy.functions import DiracDelta, Heaviside
from .integrals import Integral, integrate
from sympy.solvers import solve
def change_mul(node, x):
"""change_mul(node, x)
Rearranges the oper... |
8a77358b161a45767800b51b995ed2c918d20a5b6ac567b2446baf52693a994c | """
Algorithms for solving Parametric Risch Differential Equations.
The methods used for solving Parametric Risch Differential Equations parallel
those for solving Risch Differential Equations. See the outline in the
docstring of rde.py for more information.
The Parametric Risch Differential Equation problem is, giv... |
eb2ea784eaf3d3b229104ac7eb60a9501ad5410a23edc868251b8267d78d88d8 | from sympy.core import cacheit, Dummy, Ne, Integer, Rational, S, Wild
from sympy.functions import binomial, sin, cos, Piecewise
from .integrals import integrate
# TODO sin(a*x)*cos(b*x) -> sin((a+b)x) + sin((a-b)x) ?
# creating, each time, Wild's and sin/cos/Mul is expensive. Also, our match &
# subs are very slow wh... |
af4bc5014331fa27b0b5410de50593c71e6bc8cb829e091c8d34bc78b14867a7 | """
Integrate functions by rewriting them as Meijer G-functions.
There are three user-visible functions that can be used by other parts of the
sympy library to solve various integration problems:
- meijerint_indefinite
- meijerint_definite
- meijerint_inversion
They can be used to compute, respectively, indefinite i... |
b116d38dc788176ae4847e2fc8633d6a4c74e3e08257076b7cd2f7bb94deb794 | """
SymPy core decorators.
The purpose of this module is to expose decorators without any other
dependencies, so that they can be easily imported anywhere in sympy/core.
"""
from functools import wraps
from .sympify import SympifyError, sympify
def _sympifyit(arg, retval=None):
"""
decorator to smartly _sym... |
d99305a7af4c27b4c271d5ddf8e49e2bf7047d04eb6d55f6663495a089dfa38b | """Base class for all the objects in SymPy"""
from collections import defaultdict
from collections.abc import Mapping
from itertools import chain, zip_longest
from typing import Set, Tuple
from .assumptions import BasicMeta, ManagedProperties
from .cache import cacheit
from .sympify import _sympify, sympify, SympifyEr... |
1c5d83b2ed0b3804cad3e600e53d8b3920d8a9d42f3548fe9c7c3d38e61bdfdd | from typing import Callable, Tuple as tTuple
from math import log as _log, sqrt as _sqrt
from itertools import product
from .sympify import _sympify
from .cache import cacheit
from .singleton import S
from .expr import Expr
from .evalf import PrecisionExhausted
from .function import (expand_complex, expand_multinomial... |
d3d2d57b0b683b2280050bd878c689b9cf871bb4e326eb324ff58cc393500c3b | """Thread-safe global parameters"""
from .cache import clear_cache
from contextlib import contextmanager
from threading import local
class _global_parameters(local):
"""
Thread-local global parameters.
Explanation
===========
This class generates thread-local container for SymPy's global paramet... |
756f9bc870d76ca9a26eb0357fca8103a66afbfa9b077255d066ab76697733c5 | """Tools for manipulating of large commutative expressions. """
from .add import Add
from .mul import Mul, _keep_coeff
from .power import Pow
from .basic import Basic
from .expr import Expr
from .sympify import sympify
from .numbers import Rational, Integer, Number, I
from .singleton import S
from .sorting import defa... |
ddd07be26e5c2ad04a593520e98eb9da84ba758c2d3ffea73473642208190d4f | from collections import defaultdict
from .sympify import sympify, SympifyError
from sympy.utilities.iterables import iterable, uniq
__all__ = ['default_sort_key', 'ordered']
def default_sort_key(item, order=None):
"""Return a key that can be used for sorting.
The key has the structure:
(class_key, (l... |
32f8c5b511c78f0bbd7f3ae0d8f305bb7f7d598c60cbc32e3d8f616aa1f2b984 | """ The core's core. """
# used for canonical ordering of symbolic sequences
# via __cmp__ method:
# FIXME this is *so* irrelevant and outdated!
ordering_of_classes = [
# singleton numbers
'Zero', 'One', 'Half', 'Infinity', 'NaN', 'NegativeOne', 'NegativeInfinity',
# numbers
'Integer', 'Rational', 'Flo... |
52cc03a8ee4c380720c1e134778e986957e97a86d472dc31227874947689d3ea | """
This module contains the machinery handling assumptions.
Do also consider the guide :ref:`assumptions`.
All symbolic objects have assumption attributes that can be accessed via
``.is_<assumption name>`` attribute.
Assumptions determine certain properties of symbolic objects and can
have 3 possible values: ``True`... |
d27bdeb41235d34491e1adf15b97c836128bcbd8ff3bc726a254de6ce90d9f1c | """
There are three types of functions implemented in SymPy:
1) defined functions (in the sense that they can be evaluated) like
exp or sin; they have a name and a body:
f = exp
2) undefined function which have a name but no body. Undefined
functions can be defined using a Function cla... |
2d00640754be098990dcfdb87a2fe41dcb0cc2d6c3a1b9f706acc943eac9d47b | """Core module. Provides the basic operations needed in sympy.
"""
from .sympify import sympify, SympifyError
from .cache import cacheit
from .assumptions import assumptions, check_assumptions, failing_assumptions, common_assumptions
from .basic import Basic, Atom
from .singleton import S
from .expr import Expr, Atomi... |
e502e3885cce2afeb06e06ba437b8fffc0d63befd800fa211411409e2d29b21c | """
Module to efficiently partition SymPy objects.
This system is introduced because class of SymPy object does not always
represent the mathematical classification of the entity. For example,
``Integral(1, x)`` and ``Integral(Matrix([1,2]), x)`` are both instance
of ``Integral`` class. However the former is number an... |
6fe30bb053a677d1d9099af03df44e3192c38d5e22975f74ad44251b5ec5e937 | from .basic import Basic
from .sorting import ordered
from .sympify import sympify
from sympy.utilities.iterables import iterable
class preorder_traversal:
"""
Do a pre-order traversal of a tree.
This iterator recursively yields nodes that it has visited in a pre-order
fashion. That is, it yields th... |
014806b589b3d262285668ca54c01ae59ce50b5a796a7c64f8de12cbba5e3cda | import os
USE_SYMENGINE = os.getenv('USE_SYMENGINE', '0')
USE_SYMENGINE = USE_SYMENGINE.lower() in ('1', 't', 'true') # type: ignore
if USE_SYMENGINE:
from symengine import (Symbol, Integer, sympify, S,
SympifyError, exp, log, gamma, sqrt, I, E, pi, Matrix,
sin, cos, tan, cot, csc, sec, asin, acos... |
2ba4ba3d5996cc64aff6ff35ae74b088990c2b8767ca2f69aa3ffd9c56e2e7de | from typing import Tuple as tTuple
from collections import defaultdict
from functools import cmp_to_key, reduce
from operator import attrgetter
from .basic import Basic
from .parameters import global_parameters
from .logic import _fuzzy_group, fuzzy_or, fuzzy_not
from .singleton import S
from .operations import AssocOp... |
6ddf3bddc74b996a17b3a51f1b6baba65b5c3923f4cdfcdb065c16e4a0fa455b | """
Provides functionality for multidimensional usage of scalar-functions.
Read the vectorize docstring for more details.
"""
from functools import wraps
def apply_on_element(f, args, kwargs, n):
"""
Returns a structure with the same dimension as the specified argument,
where each basic element is repla... |
2813737fe96b5e53c0524159c865c9fba1cac723ced3793b8bfdb8e9fa6889e0 | from typing import Tuple as tTuple
from collections.abc import Iterable
from functools import reduce
from .sympify import sympify, _sympify, SympifyError
from .basic import Basic, Atom
from .singleton import S
from .evalf import EvalfMixin, pure_complex, DEFAULT_MAXPREC
from .decorators import call_highest_priority, s... |
4d1604e46a2776f104f145c0f81448104dcf3c3186e64990061a5d20df9e8092 | from typing import Dict as tDict, Union as tUnion, Type
from .basic import Atom, Basic
from .sorting import ordered
from .evalf import EvalfMixin
from .function import AppliedUndef
from .singleton import S
from .sympify import _sympify, SympifyError
from .parameters import global_parameters
from .logic import fuzzy_bo... |
d6020d3ad7cc1b420556770eee4dfac58a6aa7d170c14a22fbbbd03f60ce7032 | import numbers
import decimal
import fractions
import math
import re as regex
import sys
from functools import lru_cache
from typing import Set as tSet, Tuple as tTuple
from .containers import Tuple
from .sympify import (SympifyError, converter, sympify, _convert_numpy_types, _sympify,
_is_numpy_... |
a0daffb52c8db624cf906baa6c9c016e73fcc5214516c264173866e27d299160 | from operator import attrgetter
from typing import Tuple as tTuple, Type
from collections import defaultdict
from sympy.utilities.exceptions import SymPyDeprecationWarning
from .sympify import _sympify as _sympify_, sympify
from .basic import Basic
from .cache import cacheit
from .sorting import ordered
from .logic i... |
07c560bd1b694373ef9baf28535e4f5c92ad0083d1783fe34be2fa03279dbf58 | from .add import Add
from .exprtools import gcd_terms
from .function import Function
from .kind import NumberKind
from .logic import fuzzy_and, fuzzy_not
from .mul import Mul
from .singleton import S
class Mod(Function):
"""Represents a modulo operation on symbolic expressions.
Parameters
==========
... |
98d527ea292e9bc4bba28006bc86a3af613fcb7417bfab8daba3cfce96a7a0a9 | from .assumptions import StdFactKB, _assume_defined
from .basic import Basic, Atom
from .cache import cacheit
from .containers import Tuple
from .expr import Expr, AtomicExpr
from .function import AppliedUndef, FunctionClass
from .kind import NumberKind, UndefinedKind
from .logic import fuzzy_bool
from .singleton impor... |
23d37bb9c8619d5ca63d070a2149b1fb672e2d5c3708c903a03b5f983fe61131 | """
Reimplementations of constructs introduced in later versions of Python than
we support. Also some functions that are needed SymPy-wide and are located
here for easy import.
"""
from .sorting import ordered as _ordered, _nodes as __nodes, default_sort_key as _default_sort_key
from sympy.utilities.decorator import ... |
c6d0d7c7e945702a5e4eb1836c27f166866e5b9b46ca45568c94f63e6b6a37b4 | """sympify -- convert objects SymPy internal format"""
import typing
if typing.TYPE_CHECKING:
from typing import Any, Callable, Dict as tDict, Type
from inspect import getmro
import string
from random import choice
from .parameters import global_parameters
from sympy.utilities.exceptions import SymPyDeprecation... |
e61e4e70149b4c16668480bc9ce93769c22526df9ee4b19390cfbbde37e86dac | from .expr import Expr
from sympy.utilities.decorator import deprecated
@deprecated(useinstead="sympy.physics.quantum.trace.Tr",
deprecated_since_version="1.10", issue=22330)
class Tr(Expr):
def __new__(cls, *args):
from sympy.physics.quantum.trace import Tr
return Tr(*args)
|
b671133d291a34398e959b212875dd707fc36377968efa02bf378665a6f8daf5 | """
Adaptive numerical evaluation of SymPy expressions, using mpmath
for mathematical functions.
"""
from typing import Tuple as tTuple, Optional, Union as tUnion, Callable, List, Dict as tDict, Type, TYPE_CHECKING, \
Any, overload
import math
import mpmath.libmp as libmp
from mpmath import (
make_mpc, make_... |
807aa5fefa345090ffc37d6abcf8e45d97d3b6a851d4887e2a0b8aab7cb19f3f | r"""This is rule-based deduction system for SymPy
The whole thing is split into two parts
- rules compilation and preparation of tables
- runtime inference
For rule-based inference engines, the classical work is RETE algorithm [1],
[2] Although we are not implementing it in full (or even significantly)
it's still ... |
7222937a0537f32e969c8cfd45d132464fcd3ff33d030962a9c4419ff1aeef5a | """ Caching facility for SymPy """
class _cache(list):
""" List of cached functions """
def print_cache(self):
"""print cache info"""
for item in self:
name = item.__name__
myfunc = item
while hasattr(myfunc, '__wrapped__'):
if hasattr(myfun... |
4bd251336c622ab4cbf4e05234e2537d7c685bb7d81942472c2e3c83aef8c204 | """Module for SymPy containers
(SymPy objects that store other SymPy objects)
The containers implemented in this module are subclassed to Basic.
They are supposed to work seamlessly within the SymPy framework.
"""
from collections import OrderedDict
from collections.abc import MutableSet
from .basic imp... |
daa38603c7e090027cf1bf7cb47d8810302177f676ee04afa0f2fa2318a0d5fc | """Logic expressions handling
NOTE
----
at present this is mainly needed for facts.py, feel free however to improve
this stuff for general purpose.
"""
from typing import Dict as tDict, Type, Union as tUnion
# Type of a fuzzy bool
FuzzyBool = tUnion[bool, None]
def _torf(args):
"""Return True if all args are... |
4badf40c4af57714faf85404a4f0fe14e2f14ddc8d956d70b371dc6ece74194b | from typing import Tuple as tTuple
from collections import defaultdict
from functools import cmp_to_key, reduce
from itertools import product
import operator
from .sympify import sympify
from .basic import Basic
from .singleton import S
from .operations import AssocOp, AssocOpDispatcher
from .cache import cacheit
from... |
7c280f0066427bc353d0bc4358bd329f5b0085268aa68d2ea26ff05fce8ca687 | """Tools for setting up printing in interactive sessions. """
from sympy.external.importtools import version_tuple
from io import BytesIO
from sympy.printing.latex import latex as default_latex
from sympy.printing.preview import preview
from sympy.utilities.misc import debug
from sympy.printing.defaults import Printa... |
ca893010ed8717778dd97bbae494a9514b0de226263efbd4e26ffae1fdd0df7a | """Helper module for setting up interactive SymPy sessions. """
from .printing import init_printing
from .session import init_session
from .traversal import interactive_traversal
__all__ = ['init_printing', 'init_session', 'interactive_traversal']
|
16dc035695fc0b4f407dd727a6133af9a87ced29315103a6a2cf4ecaf01302e9 | """Tools for setting up interactive sessions. """
from sympy.external.gmpy import GROUND_TYPES
from sympy.external.importtools import version_tuple
from sympy.interactive.printing import init_printing
from sympy.utilities.misc import ARCH
preexec_source = """\
from __future__ import division
from sympy import *
x, ... |
5db71c74eea6b0d02fac6e851499769f85e62224484a7bdd6b841f95f10f83b5 | from sympy.core.basic import Basic
from sympy.printing import pprint
import random
def interactive_traversal(expr):
"""Traverse a tree asking a user which branch to choose. """
RED, BRED = '\033[0;31m', '\033[1;31m'
GREEN, BGREEN = '\033[0;32m', '\033[1;32m'
YELLOW, BYELLOW = '\033[0;33m', '\033[1;33... |
5030d50fbc0b8158582c3b38080df76fb0891659ef433ed35a3ea51ba5ef9e0d | """Definitions of monomial orderings. """
from typing import Optional
__all__ = ["lex", "grlex", "grevlex", "ilex", "igrlex", "igrevlex"]
from sympy.core import Symbol
from sympy.utilities.iterables import iterable
class MonomialOrder:
"""Base class for monomial orderings. """
alias = None # type: Option... |
3ea4eba70f27b0d13c372505915bc1d9976053f4fc021b50d951025866176f3c | """Power series evaluation and manipulation using sparse Polynomials
Implementing a new function
---------------------------
There are a few things to be kept in mind when adding a new function here::
- The implementation should work on all possible input domains/rings.
Special cases include the ``EX`` rin... |
a99bfa4b55aa3a2c5ed4187f5d82c18f582c17b3a0165a2354337ce8201135e6 | """OO layer for several polynomial representations. """
from sympy.core.numbers import oo
from sympy.core.sympify import CantSympify
from sympy.polys.polyerrors import CoercionFailed, NotReversible, NotInvertible
from sympy.polys.polyutils import PicklableWithSlots
class GenericPoly(PicklableWithSlots):
"""Base... |
dbee3c260b01d39f871eed4aaba30e549b0be07b41d4e0f98343a8e95df81dfe | """Implementation of RootOf class and related tools. """
from sympy.core.basic import Basic
from sympy.core import (S, Expr, Integer, Float, I, oo, Add, Lambda,
symbols, sympify, Rational, Dummy)
from sympy.core.cache import cacheit
from sympy.core.relational import is_le
from sympy.core.sorting import ordered
fr... |
bab28740512001d8105a8f414ad5f2cbd463bacf072e8c71a1a4b48dfdd3d953 | """User-friendly public interface to polynomial functions. """
from functools import wraps, reduce
from operator import mul
from sympy.core import (
S, Expr, Add, Tuple
)
from sympy.core.basic import Basic
from sympy.core.decorators import _sympifyit
from sympy.core.exprtools import Factors, factor_nc, factor_te... |
9a8c383566e1268a270d3f5839647c8dd19fc5d168f2092cc435e305a6685d06 | """Functions for generating interesting polynomials, e.g. for benchmarking. """
from sympy.core import Add, Mul, Symbol, sympify, Dummy, symbols
from sympy.core.containers import Tuple
from sympy.core.singleton import S
from sympy.functions.elementary.miscellaneous import sqrt
from sympy.ntheory import nextprime
from... |
29866e3f80b100ddca3fa21fde1339dc728ce12f3bacd5361de7306d88d67ce1 | """Implementation of matrix FGLM Groebner basis conversion algorithm. """
from sympy.polys.monomials import monomial_mul, monomial_div
def matrix_fglm(F, ring, O_to):
"""
Converts the reduced Groebner basis ``F`` of a zero-dimensional
ideal w.r.t. ``O_from`` to a reduced Groebner basis
w.r.t. ``O_to`... |
1fd0e29a6139ccbb84a73c98bd35815620494dee5b6cb8fed5179f680cb65d79 | """Basic tools for dense recursive polynomials in ``K[x]`` or ``K[X]``. """
from sympy.core.numbers import oo
from sympy.core import igcd
from sympy.polys.monomials import monomial_min, monomial_div
from sympy.polys.orderings import monomial_key
import random
def poly_LC(f, K):
"""
Return leading coefficien... |
c02ffe6643dd647f25a16eaa2561f34119ec52a9a807c4dd75cd8e424a309704 | """Algorithms for computing symbolic roots of polynomials. """
import math
from functools import reduce
from sympy.core import S, I, pi
from sympy.core.exprtools import factor_terms
from sympy.core.function import _mexpand
from sympy.core.logic import fuzzy_not
from sympy.core.mul import expand_2arg, Mul
from sympy.... |
dd6edd1e836f911e4251d0e10796fdf54b296eec9ee810959c0329e8ed7dfc5a | """Arithmetics for dense recursive polynomials in ``K[x]`` or ``K[X]``. """
from sympy.polys.densebasic import (
dup_slice,
dup_LC, dmp_LC,
dup_degree, dmp_degree,
dup_strip, dmp_strip,
dmp_zero_p, dmp_zero,
dmp_one_p, dmp_one,
dmp_ground, dmp_zeros)
from sympy.polys.polyerrors import (Exa... |
8cc85065ff5553ccf16911ac89cb669ea97ecddca5848f65f2cac4f675198bc8 | """Dense univariate polynomials with coefficients in Galois fields. """
from random import uniform
from math import ceil as _ceil, sqrt as _sqrt
from sympy.core.mul import prod
from sympy.external.gmpy import SYMPY_INTS
from sympy.ntheory import factorint
from sympy.polys.polyconfig import query
from sympy.polys.pol... |
e9e090ac4fc8cf93a4d16693cc28b6142f14613f49a7f0624cd552717c81134b | """
This module contains functions for the computation
of Euclidean, (generalized) Sturmian, (modified) subresultant
polynomial remainder sequences (prs's) of two polynomials;
included are also three functions for the computation of the
resultant of two polynomials.
Except for the function res_z(), which computes the ... |
6720d9f482607c3e9f64fe07110d46b1f831a1fe62203596c29731e075e1fd2f | """Sparse polynomial rings. """
from typing import Any, Dict as tDict
from operator import add, mul, lt, le, gt, ge
from functools import reduce
from types import GeneratorType
from sympy.core.expr import Expr
from sympy.core.numbers import igcd, oo
from sympy.core.symbol import Symbol, symbols as _symbols
from sym... |
86a1543c55ba91460a985832ed0216ba418e9071f1e037303097672c21455f74 | """Options manager for :class:`~.Poly` and public API functions. """
__all__ = ["Options"]
from typing import Dict as tDict, Type
from typing import List, Optional
from sympy.core import Basic, sympify
from sympy.polys.polyerrors import GeneratorsError, OptionError, FlagError
from sympy.utilities import numbered_sy... |
ac482b7db124fb2eba9ac83fcaace3626cf1783263dc164b11d5fd0044988d7e | """Groebner bases algorithms. """
from sympy.core.symbol import Dummy
from sympy.polys.monomials import monomial_mul, monomial_lcm, monomial_divides, term_div
from sympy.polys.orderings import lex
from sympy.polys.polyerrors import DomainError
from sympy.polys.polyconfig import query
def groebner(seq, ring, method=N... |
09ae1d7ae1b3005e675ef8b7fc727480aef50a9351dbffb597c74906d9797667 | """Definitions of common exceptions for `polys` module. """
from sympy.utilities import public
@public
class BasePolynomialError(Exception):
"""Base class for polynomial related exceptions. """
def new(self, *args):
raise NotImplementedError("abstract base class")
@public
class ExactQuotientFailed(... |
bc4e7b649bf588934a1dc45b1490601ba272b6e7707aadf0c8307dd32c6d1427 | from sympy.core.symbol import Dummy
from sympy.ntheory import nextprime
from sympy.ntheory.modular import crt
from sympy.polys.domains import PolynomialRing
from sympy.polys.galoistools import (
gf_gcd, gf_from_dict, gf_gcdex, gf_div, gf_lcm)
from sympy.polys.polyerrors import ModularGCDFailed
from mpmath import s... |
5232b6503e58f6af08c8a9aff64b01f9d52c556b2936d39e02a9a168d110a693 | """High-level polynomials manipulation functions. """
from sympy.core import S, Basic, Add, Mul, symbols, Dummy
from sympy.polys.polyerrors import (
PolificationFailed, ComputationFailed,
MultivariatePolynomialError, OptionError)
from sympy.polys.polyoptions import allowed_flags
from sympy.polys.polytools imp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.