hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
7dc3f64ff52293a7ebb9c91d48b9f2ba54c63fe24eb7a9cb754054e7c085c94f | import sys
sys._running_pytest = True # type: ignore
from distutils.version import LooseVersion as V
import pytest
from sympy.core.cache import clear_cache
import re
sp = re.compile(r'([0-9]+)/([1-9][0-9]*)')
def process_split(config, items):
split = config.getoption("--split")
if not split:
return
... |
3861d7ed5195f05f9d07f5161360ab694893a1a257001f9ef7325324f49c060f | __version__ = "1.8.dev"
|
c41b6ec7cd8316a22cefcbd855c0f976935539297e72afdaebb464ed84ee2d1a | """
This module exports all latin and greek letters as Symbols, so you can
conveniently do
>>> from sympy.abc import x, y
instead of the slightly more clunky-looking
>>> from sympy import symbols
>>> x, y = symbols('x y')
Caveats
=======
1. As of the time of writing this, the names ``C``, ``O``, ``S``,... |
cd11e92bdc44b45374069b191a3ce010b0c0cd7bb98d9836b8900c8138101ecc | """
Continuous Random Variables - Prebuilt variables
Contains
========
Arcsin
Benini
Beta
BetaNoncentral
BetaPrime
BoundedPareto
Cauchy
Chi
ChiNoncentral
ChiSquared
Dagum
Erlang
ExGaussian
Exponential
ExponentialPower
FDistribution
FisherZ
Frechet
Gamma
GammaInverse
Gumbel
Gompertz
Kumaraswamy
Laplace
Levy
Logistic
Lo... |
65c15591aa99adb2cd607d96465393711b882d1b40925d999cc025233f0a9e92 | """
Finite Discrete Random Variables - Prebuilt variable types
Contains
========
FiniteRV
DiscreteUniform
Die
Bernoulli
Coin
Binomial
BetaBinomial
Hypergeometric
Rademacher
"""
from sympy import (S, sympify, Rational, binomial, cacheit, Integer,
Dummy, Eq, Intersection, Interval,
... |
0b964834b4ced5429f410f052ba38d6c628f7a05b5bda2bfde7d0edf169b50a1 | import random
import itertools
from typing import Sequence as tSequence, Union as tUnion, List as tList, Tuple as tTuple
from sympy import (Matrix, MatrixSymbol, S, Indexed, Basic, Tuple, Range,
Set, And, Eq, FiniteSet, ImmutableMatrix, Integer, igcd,
Lambda, Mul, Dummy, IndexedB... |
11006d95d054685811a86705e3bedec66da29b1dd21a490cd39c1962ce6d08bf | from sympy import Basic
from sympy.stats.rv import PSpace, _symbol_converter, RandomMatrixSymbol
class RandomMatrixPSpace(PSpace):
"""
Represents probability space for
random matrices. It contains the mechanics
for handling the API calls for random matrices.
"""
def __new__(cls, sym, model=None... |
a75326df053687003ca2dad0e6d5a64c94ffd90f58329f227a4b8a82bf185057 | """Tools for arithmetic error propagation."""
from itertools import repeat, combinations
from sympy import S, Symbol, Add, Mul, simplify, Pow, exp
from sympy.stats.symbolic_probability import RandomSymbol, Variance, Covariance
from sympy.stats.rv import is_random
_arg0_or_var = lambda var: var.args[0] if len(var.arg... |
c2a7db439ebd009d6dcf09cedeb15172aad81627f4f11279bb73b229188d4eb0 | """
Contains
========
Geometric
Hermite
Logarithmic
NegativeBinomial
Poisson
Skellam
YuleSimon
Zeta
"""
from sympy import (Basic, factorial, exp, S, sympify, I, zeta, polylog, log, beta,
hyper, binomial, Piecewise, floor, besseli, sqrt, Sum, Dummy,
Lambda, Eq)
from sympy.stats.... |
853eeaa953001805a1b43ff9e77c108e4bb4a60cb7c1158a239a22286ae74e09 | from sympy.sets import FiniteSet
from sympy import (sqrt, log, exp, FallingFactorial, Rational, Eq, Dummy,
piecewise_fold, solveset, Integral)
from .rv import (probability, expectation, density, where, given, pspace, cdf, PSpace,
characteristic_function, sample, sample_iter, random_symb... |
0b11e6a3403228ec07bd8d08ede68446f5662cc9868519ae065f4ea404df35ad | """
Main Random Variables Module
Defines abstract random variable type.
Contains interfaces for probability space object (PSpace) as well as standard
operators, P, E, sample, density, where, quantile
See Also
========
sympy.stats.crv
sympy.stats.frv
sympy.stats.rv_interface
"""
from functools import singledispatch... |
3ec3b41e784781b8dc39b74b7e6ed3ca520d02083b7690e4e9c699edeafd04ea | """
Joint Random Variables Module
See Also
========
sympy.stats.rv
sympy.stats.frv
sympy.stats.crv
sympy.stats.drv
"""
from sympy import (Basic, Lambda, sympify, Indexed, Symbol, ProductSet, S,
Dummy)
from sympy.concrete.products import Product
from sympy.concrete.summations import Sum, summation
... |
c30e893f2554adef2f886678a8a85be79908b7c7b9b726943074544f290d8935 | from sympy import (Basic, sympify, symbols, Dummy, Lambda, summation,
Piecewise, S, cacheit, Sum, exp, I, Ne, Eq, poly,
series, factorial, And, lambdify)
from sympy.polys.polyerrors import PolynomialError
from sympy.stats.crv import reduce_rational_inequalities_wrap
from sympy.sta... |
c833bb8dafda6367b4f45cddf8245fd73073893589964a5f17201d8342174243 | """
Continuous Random Variables Module
See Also
========
sympy.stats.crv_types
sympy.stats.rv
sympy.stats.frv
"""
from sympy import (Interval, Intersection, symbols, sympify, Dummy, nan,
Integral, And, Or, Piecewise, cacheit, integrate, oo, Lambda,
Basic, S, exp, I, FiniteSet, Ne, Eq, Union, poly, se... |
83472ee206ac646412cae109c880a39296e5fb4293fea8195be98dfdbbb14919 | from sympy import Basic, Sum, Dummy, Lambda, Integral
from sympy.stats.rv import (NamedArgsMixin, random_symbols, _symbol_converter,
PSpace, RandomSymbol, is_random)
from sympy.stats.crv import ContinuousDistribution, SingleContinuousPSpace
from sympy.stats.drv import DiscreteDistribution, Singl... |
8c20011283a91f32ae0eedbc864de362e825d8582d0fe6667c951b9bcb9ef67c | import itertools
from sympy import (Expr, Add, Mul, S, Integral, Eq, Sum, Symbol,
expand as _expand, Not)
from sympy.core.compatibility import default_sort_key
from sympy.core.parameters import global_parameters
from sympy.core.sympify import _sympify
from sympy.core.relational import Relational
fr... |
c9e18e2774e69ca828c9df209d651ec4aff2aaabb0eafbc599719921fd59f224 | from sympy import (Basic, exp, pi, Lambda, Trace, S, MatrixSymbol, Integral,
gamma, Product, Dummy, Sum, Abs, IndexedBase, I)
from sympy.core.sympify import _sympify
from sympy.stats.rv import _symbol_converter, Density, RandomMatrixSymbol, is_random
from sympy.stats.joint_rv_types import JointDistri... |
06c176ccf7c83f0d5dfc72b2be45b9b18c5cb1de057e1229f9cd948b4792175a | """
Finite Discrete Random Variables Module
See Also
========
sympy.stats.frv_types
sympy.stats.rv
sympy.stats.crv
"""
from itertools import product
from sympy import (Basic, Symbol, cacheit, sympify, Mul,
And, Or, Piecewise, Eq, Lambda, exp, I, Dummy, nan,
Sum, Intersection, S)
... |
7e6a197e0deb9c9f325e29a7ee46107dcff7a3760a051d0aec207cdba04111fa | from sympy import Basic
from sympy.stats.joint_rv import ProductPSpace
from sympy.stats.rv import ProductDomain, _symbol_converter
class StochasticPSpace(ProductPSpace):
"""
Represents probability space of stochastic processes
and their random variables. Contains mechanics to do
computations for queri... |
f06411db8a8e5e375294eaaa3908318a126056525e5a0881a1245a7e56f61d8a | from sympy.combinatorics import Permutation
from sympy.combinatorics.util import _distribute_gens_by_base
rmul = Permutation.rmul
def _cmp_perm_lists(first, second):
"""
Compare two lists of permutations as sets.
Explanation
===========
This is used for testing purposes. Since the array form of... |
3d1a58d440d65b2b096de9751356033803b160020f51a13da8e5b54795a73acb | from random import randrange, choice
from math import log
from sympy.ntheory import primefactors
from sympy import multiplicity, factorint, Symbol
from sympy.combinatorics import Permutation
from sympy.combinatorics.permutations import (_af_commutes_with, _af_invert,
_af_rmul, _af_rmuln, _af_pow, Cycle)
from sympy... |
63ed4e6adc5ac1d4a921424f2c62fef8853e61b9caab3fc64142548895f0d48d | import random
from collections import defaultdict
from sympy.core.parameters import global_parameters
from sympy.core.basic import Atom
from sympy.core.expr import Expr
from sympy.core.compatibility import \
is_sequence, reduce, as_int, Iterable
from sympy.core.numbers import Integer
from sympy.core.sympify import... |
dcbff30c138b49b2ba5c8435bedee7ec8b793900e080202fb10db1224d56aa56 | from itertools import combinations
from sympy.combinatorics.graycode import GrayCode
from sympy.core import Basic
class Subset(Basic):
"""
Represents a basic subset object.
Explanation
===========
We generate subsets using essentially two techniques,
binary enumeration and lexicographic enu... |
20ac75dbfc9626a110ee0fa806e0167795512db08e5b22f42c6e0f42ee37052f | from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.combinatorics.permutations import Permutation
from sympy.utilities.iterables import uniq
_af_new = Permutation._af_new
def DirectProduct(*groups):
"""
Returns the direct product of several groups as a permutation group.
Explanation
... |
e606bdf433557bb0e9363559f9b0d58af0c56dde60895b16bda3bfe1546a88ff | from sympy.combinatorics.permutations import Permutation, _af_rmul, \
_af_invert, _af_new
from sympy.combinatorics.perm_groups import PermutationGroup, _orbit, \
_orbit_transversal
from sympy.combinatorics.util import _distribute_gens_by_base, \
_orbits_transversals_from_bsgs
"""
References for tensor ... |
7980f821d4c2d10739349db72691d4e9292c8317bb12a550f1a34a0466e180f3 | from sympy import isprime
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.printing.defaults import DefaultPrinting
from sympy.combinatorics.free_groups import free_group
class PolycyclicGroup(DefaultPrinting):
is_group = True
is_solvable = True
def __init__(self, pc_sequence, pc_... |
b356a6b760fffb62e9f4a9615d26e6716ea5c1c47add792a123d95aba509a5d6 | from sympy.combinatorics import Permutation as Perm
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.core import Basic, Tuple
from sympy.core.compatibility import as_int
from sympy.sets import FiniteSet
from sympy.utilities.iterables import (minlex, unflatten, flatten)
rmul = Perm.rmul
class P... |
154b1e85fb2ec21248a0d65c1c0bc33949f23361183bf4e26e83094c9d58e7cf | import itertools
from sympy.combinatorics.fp_groups import FpGroup, FpSubgroup, simplify_presentation
from sympy.combinatorics.free_groups import FreeGroup
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.core.numbers import igcd
from sympy.ntheory.factor_ import totient
from sympy import S
clas... |
9565b5f31f6b52a1711728114843fecc9843c6179d18e729c9945f8cee9e4b02 | from sympy.core import Basic, Dict, sympify
from sympy.core.compatibility import as_int, default_sort_key
from sympy.core.sympify import _sympify
from sympy.functions.combinatorial.numbers import bell
from sympy.matrices import zeros
from sympy.sets.sets import FiniteSet, Union
from sympy.utilities.iterables import fla... |
8623821dff0c0e6e9e487fee93f54fbf2677ac5735901ac5dd6cc51e85fff678 | from sympy.combinatorics.permutations import Permutation, _af_invert, _af_rmul
from sympy.ntheory import isprime
rmul = Permutation.rmul
_af_new = Permutation._af_new
############################################
#
# Utilities for computational group theory
#
############################################
def _base_or... |
8026745e91aed7a9e06c1461e66801e858648459e3b3010d6f91f590b762c781 | from sympy.combinatorics.group_constructs import DirectProduct
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.combinatorics.permutations import Permutation
_af_new = Permutation._af_new
def AbelianGroup(*cyclic_orders):
"""
Returns the direct product of cyclic groups with the given o... |
b469c409285f40e99271b4fd2d8158e2101659962af8d7ff68794a281de4705b | from sympy import Integer
from sympy.core import Symbol
from sympy.utilities import public
@public
def approximants(l, X=Symbol('x'), simplify=False):
"""
Return a generator for consecutive Pade approximants for a series.
It can also be used for computing the rational generating function of a
series wh... |
d37dcd27945ef004b87aaf9c8667dcb77f8bcf6bc1a9d16a5ed9eb6f1b304f1d | """
Contains the base class for series
Made using sequences in mind
"""
from sympy.core.expr import Expr
from sympy.core.singleton import S
from sympy.core.cache import cacheit
class SeriesBase(Expr):
"""Base Class for series"""
@property
def interval(self):
"""The interval on which the series i... |
72b4a440ad7003a15000a2358ac946eaba40cef5a5cf581964fc76030a78dd08 | from sympy.core.sympify import sympify
def series(expr, x=None, x0=0, n=6, dir="+"):
"""Series expansion of expr around point `x = x0`.
Parameters
==========
expr : Expression
The expression whose series is to be expanded.
x : Symbol
It is the variable of the expression to be... |
7075464506b36b86b2a88ea38ba38736475010c57b064a387f8bee8366ee1106 | from sympy.core.sympify import sympify
def aseries(expr, x=None, n=6, bound=0, hir=False):
"""
See the docstring of Expr.aseries() for complete details of this wrapper.
"""
expr = sympify(expr)
return expr.aseries(x, n, bound, hir)
|
ecbf10de75ef3b36145a643cbaec3bd045061e5f9afb83f83953214eb1a9337d | """
Convergence acceleration / extrapolation methods for series and
sequences.
References:
Carl M. Bender & Steven A. Orszag, "Advanced Mathematical Methods for
Scientists and Engineers: Asymptotic Methods and Perturbation Theory",
Springer 1999. (Shanks transformation: pp. 368-375, Richardson
extrapolation: pp. 375-3... |
7e6503609ee98d51720d7e261f57f930c5a147cf7bbcad96b064446db53698d3 | """
Limits
======
Implemented according to the PhD thesis
http://www.cybertester.com/data/gruntz.pdf, which contains very thorough
descriptions of the algorithm including many examples. We summarize here
the gist of it.
All functions are sorted according to how rapidly varying they are at
infinity using the followin... |
7fb8f5541de050478d729516884b9bac61c2cf5e21939ec52bb18a2b00bd036e | from sympy.core.basic import Basic
from sympy.core.cache import cacheit
from sympy.core.compatibility import is_sequence, iterable, ordered
from sympy.core.containers import Tuple
from sympy.core.decorators import call_highest_priority
from sympy.core.parameters import global_parameters
from sympy.core.function import ... |
53ec675f12ed86d53c3ce4201d982e01f27e6b10e33a0ad9d3df5319bcd926b3 | from sympy.core import S, Symbol, Add, sympify, Expr, PoleError, Mul
from sympy.core.exprtools import factor_terms
from sympy.core.symbol import Dummy
from sympy.functions.combinatorial.factorials import factorial
from sympy.functions.special.gamma_functions import gamma
from sympy.polys import PolynomialError, factor
... |
468436b1499e66d2ade09cff6a77a7eff94c065ce9cb7f3db10be053d58dfb09 | """Limits of sequences"""
from sympy.core.add import Add
from sympy.core.function import PoleError
from sympy.core.power import Pow
from sympy.core.singleton import S
from sympy.core.symbol import Dummy
from sympy.core.sympify import sympify
from sympy.functions.combinatorial.numbers import fibonacci
from sympy.functi... |
8844cdb1f5e648976b6fbc504dc3502f1267e18e232d1f199091c7d0f3366078 | """Fourier Series"""
from sympy import pi, oo, Wild
from sympy.core.expr import Expr
from sympy.core.add import Add
from sympy.core.compatibility import is_sequence
from sympy.core.containers import Tuple
from sympy.core.singleton import S
from sympy.core.symbol import Dummy, Symbol
from sympy.core.sympify import symp... |
5844a3acac836e1030ec18ed03e3b63e1ca71213790653f69a4f9c62cfffe584 | """
This module implements the Residue function and related tools for working
with residues.
"""
from sympy import sympify
from sympy.utilities.timeutils import timethis
@timethis('residue')
def residue(expr, x, x0):
"""
Finds the residue of ``expr`` at the point x=x0.
The residue is defined as the coef... |
2f39430a9d0224e848a62b0f493977273a4cc94f377d5a4fd9d626f0172e0b5a | """Formal Power Series"""
from collections import defaultdict
from sympy import oo, zoo, nan
from sympy.core.add import Add
from sympy.core.compatibility import iterable
from sympy.core.expr import Expr
from sympy.core.function import Derivative, Function, expand
from sympy.core.mul import Mul
from sympy.core.numbers... |
ea177139aa1de3f6c399e78491604b67c106794bccb7b6a951acdfb9df5812c5 | from sympy.core import S, sympify, Expr, Rational, Dummy
from sympy.core import Add, Mul, expand_power_base, expand_log
from sympy.core.cache import cacheit
from sympy.core.compatibility import default_sort_key, is_sequence
from sympy.core.containers import Tuple
from sympy.sets.sets import Complement
from sympy.utilit... |
3f30f43004cc3632e33e2f465b919018be94a9cd944feb8fc27ce18bb4e4247f | def finite_diff(expression, variable, increment=1):
"""
Takes as input a polynomial expression and the variable used to construct
it and returns the difference between function's value when the input is
incremented to 1 and the original function value. If you want an increment
other than one supply ... |
0607859c45509e32175013678990c98684543b1f679756914d2de9fad97e066a | """
Expand Hypergeometric (and Meijer G) functions into named
special functions.
The algorithm for doing this uses a collection of lookup tables of
hypergeometric functions, and various of their properties, to expand
many hypergeometric functions in terms of special functions.
It is based on the following paper:
... |
9757d440686b51570176973fdb0aaf5b5fcbc34bd1bdc319c324164204422a18 | """ Optimizations of the expression tree representation for better CSE
opportunities.
"""
from sympy.core import Add, Basic, Mul
from sympy.core.basic import preorder_traversal
from sympy.core.singleton import S
from sympy.utilities.iterables import default_sort_key
def sub_pre(e):
""" Replace y - x with -(x - y)... |
ea1de60622e3707d7965d962f692b4e2346663147cb860dce0bb5f00c6b9e52d | from collections import defaultdict
from sympy.core import (Basic, S, Add, Mul, Pow, Symbol, sympify,
expand_func, Function, Dummy, Expr, factor_terms,
expand_power_exp, Eq)
from sympy.core.compatibility import iterable, ordered, as_int
from sympy.core.parameters import ... |
87332005ca78b461da90cbc74b0568b8a67818df30d6e7ffdb97e41f6294405f | """Tools for applying functions to specified parts of expressions. """
from sympy.core import sympify
def use(expr, func, level=0, args=(), kwargs={}):
"""
Use ``func`` to transform ``expr`` at the given level.
Examples
========
>>> from sympy import use, expand
>>> from sympy.abc import x,... |
6c1b4a8bf7bd8ff6aa680c23c9ba36060aaba78928c502ea4ac98624b79c1988 | from collections import defaultdict
from sympy import SYMPY_DEBUG
from sympy.core import expand_power_base, sympify, Add, S, Mul, Derivative, Pow, symbols, expand_mul
from sympy.core.add import _unevaluated_Add
from sympy.core.compatibility import iterable, ordered, default_sort_key
from sympy.core.parameters import ... |
35102055e5581845da44d59a64f8df8ca3602e598978cfa2698213b7e62a5d2b | """Tools for manipulation of expressions using paths. """
from sympy.core import Basic
class EPath:
r"""
Manipulate expressions using paths.
EPath grammar in EBNF notation::
literal ::= /[A-Za-z_][A-Za-z_0-9]*/
number ::= /-?\d+/
type ::= literal
attribute ::= ... |
a8029e2ba01f3f74c6531cab6bd69f7a122ed75d8ecd345234e2d91eddb775f4 | from sympy.core import Mul
from sympy.core.basic import preorder_traversal
from sympy.core.function import count_ops
from sympy.functions.combinatorial.factorials import binomial, factorial
from sympy.functions import gamma
from sympy.simplify.gammasimp import gammasimp, _gammasimp
from sympy.utilities.timeutils impor... |
7e51bf655cdc6a8bbe60c10138c6204747ba3d7f28108a3ec75bdab3c055b72c | from sympy.core import Add, Expr, Mul, S, sympify
from sympy.core.function import _mexpand, count_ops, expand_mul
from sympy.core.symbol import Dummy
from sympy.functions import root, sign, sqrt
from sympy.polys import Poly, PolynomialError
from sympy.utilities import default_sort_key
def is_sqrt(expr):
"""Return... |
dedea045629a9e7426b27000dd5ed4e0484979f8f2fe6e670f98a1a6aff17940 | from collections import defaultdict
from sympy.core.function import expand_log, count_ops
from sympy.core import sympify, Basic, Dummy, S, Add, Mul, Pow, expand_mul, factor_terms
from sympy.core.compatibility import ordered, default_sort_key, reduce
from sympy.core.numbers import Integer, Rational
from sympy.core.mul ... |
0bf150af2b5a340b38eeeac388b9b62ce263c692768c3b697e04659a984923ce | from sympy.core import Function, S, Mul, Pow, Add
from sympy.core.compatibility import ordered, default_sort_key
from sympy.core.function import count_ops, expand_func
from sympy.functions.combinatorial.factorials import binomial
from sympy.functions import gamma, sqrt, sin
from sympy.polys import factor, cancel
from ... |
e381b806646ed3ea8fd1280303b457cfb59c29dfc4986c44aaab050d544235dd | from collections import defaultdict
from sympy.core import (sympify, Basic, S, Expr, expand_mul, factor_terms,
Mul, Dummy, igcd, FunctionClass, Add, symbols, Wild, expand)
from sympy.core.cache import cacheit
from sympy.core.compatibility import reduce, iterable, SYMPY_INTS
from sympy.core.function import count_op... |
99eb4868fae8df81d96636f8d8b7e2d8e496eb20494cb78c3e7f605caba04a7e | """ Tools for doing common subexpression elimination.
"""
from sympy.core import Basic, Mul, Add, Pow, sympify, Symbol
from sympy.core.compatibility import iterable
from sympy.core.containers import Tuple, OrderedSet
from sympy.core.exprtools import factor_terms
from sympy.core.function import _coeff_isneg
from sympy.c... |
daa9e086514933f6bdcd1d99ff39fd392d2ebd56fbe575774ab4e0421f77ffbe | from collections import defaultdict
from sympy.core.add import Add
from sympy.core.basic import S
from sympy.core.compatibility import ordered
from sympy.core.expr import Expr
from sympy.core.exprtools import Factors, gcd_terms, factor_terms
from sympy.core.function import expand_mul
from sympy.core.mul import Mul
fro... |
55e107182ad69fdd4bea9061664d2eaebfee9062558cb6462b580df38506facc | """ This module cooks up a docstring when imported. Its only purpose is to
be displayed in the sphinx documentation. """
from sympy import latex, Eq, hyper
from sympy.simplify.hyperexpand import FormulaCollection
c = FormulaCollection()
doc = ""
for f in c.formulae:
obj = Eq(hyper(f.func.ap, f.func.bq, f.z)... |
1ab8af4bff62a9ce031d149a748a0b74ec49773e9eb9dcad3d90fc3c5830a346 | from itertools import combinations_with_replacement
from sympy.core import symbols, Add, Dummy
from sympy.core.numbers import Rational
from sympy.polys import cancel, ComputationFailed, parallel_poly_from_expr, reduced, Poly
from sympy.polys.monomials import Monomial, monomial_div
from sympy.polys.polyerrors import Dom... |
cab556bc3f59419547746c326c3d37caedeaaa73a68a721e961ad6c1290d80bf | from typing import Any, Set
from itertools import permutations
from sympy.combinatorics import Permutation
from sympy.core import (
Basic, Expr, Function, diff,
Pow, Mul, Add, Atom, Lambda, S, Tuple, Dict
)
from sympy.core.cache import cacheit
from sympy.core.compatibility import reduce
from sympy.core.symbol... |
e41fcf0c8e414118cb92fc5bd29ab382457035653c415a29bdf5ac158d9c48c9 | """
AST nodes specific to the C family of languages
"""
from sympy.codegen.ast import (
Attribute, Declaration, Node, String, Token, Type, none,
FunctionCall, CodeBlock
)
from sympy.core.basic import Basic
from sympy.core.containers import Tuple
from sympy.core.sympify import sympify
void = Type('void')
... |
7ea671bab2fca64a2d592c8f137a7460a29848eb7c40afa0cb1c0176202f1380 | import bisect
import itertools
from functools import reduce
from collections import defaultdict
from sympy import Indexed, IndexedBase, Tuple, Sum, Add, S, Integer, diagonalize_vector, DiagMatrix
from sympy.combinatorics import Permutation
from sympy.core.basic import Basic
from sympy.core.compatibility import accumul... |
9a00e866fba102613418c91f5e9295fef7da15cefed39ca180fb376eea1fb675 | """
Additional AST nodes for operations on matrices. The nodes in this module
are meant to represent optimization of matrix expressions within codegen's
target languages that cannot be represented by SymPy expressions.
As an example, we can use :meth:`sympy.codegen.rewriting.optimize` and the
``matin_opt`` optimizatio... |
af2a3731ef0028c090a6a0908bd2ba653a6c17a26cec5b11a4473d1ab5369c2b | """
This file contains some classical ciphers and routines
implementing a linear-feedback shift register (LFSR)
and the Diffie-Hellman key exchange.
.. warning::
This module is intended for educational purposes only. Do not use the
functions in this module for real cryptographic applications. If you wish
to ... |
995dbc94b5fcf1e2a06ce72aa655d2eeb83c6caff96e7299dfaf4e7e8a024e22 | from sympy.core.add import Add
from sympy.core.compatibility import ordered
from sympy.core.function import expand_log
from sympy.core.power import Pow
from sympy.core.singleton import S
from sympy.core.symbol import Dummy
from sympy.functions.elementary.exponential import (LambertW, exp, log)
from sympy.functions.elem... |
6979c6ce6a257f2ae9f98793ac839436534e4ab9bddc03a0420acae110359871 | r"""
This module is intended for solving recurrences or, in other words,
difference equations. Currently supported are linear, inhomogeneous
equations with polynomial or rational coefficients.
The solutions are obtained among polynomials, rational functions,
hypergeometric terms, or combinations of hypergeometric term... |
582902239582005a55a76cf702ba605404b6fb238f1258a08d9bd066c7e8a215 | """
This module contains functions to:
- solve a single equation for a single variable, in any domain either real or complex.
- solve a single transcendental equation for a single variable in any domain either real or complex.
(currently supports solving in real domain only)
- solve a system of lin... |
e550a4452e5c95ebe56244e1588b39c16741db74e8a21a9287ce29fd39236fcb | """
This module contains pdsolve() and different helper functions that it
uses. It is heavily inspired by the ode module and hence the basic
infrastructure remains the same.
**Functions in this module**
These are the user functions in this module:
- pdsolve() - Solves PDE's
- classify_pde() - Classif... |
41628ff36fc8874595494c5e1678fcbb8aae32012e79e69320be404666a9dd9e | """Utility functions for classifying and solving
ordinary and partial differential equations.
Contains
========
_preprocess
ode_order
_desolve
"""
from sympy.core import Pow
from sympy.core.function import Derivative, AppliedUndef
from sympy.core.relational import Equality
from sympy.core.symbol import Wild
def _pre... |
fa495579c64fa1f211572a6625d7654afad8c46be569e839f71d86bd4b7b5811 | """Solvers of systems of polynomial equations. """
from sympy.core import S
from sympy.polys import Poly, groebner, roots
from sympy.polys.polytools import parallel_poly_from_expr
from sympy.polys.polyerrors import (ComputationFailed,
PolificationFailed, CoercionFailed)
from sympy.simplify import rcollect
from sym... |
2e1fd921dca5bc48d487b2c42feb036a6b6763ddafd9cc48952cb3e3e966f952 | """Tools for solving inequalities and systems of inequalities. """
from sympy.core import Symbol, Dummy, sympify
from sympy.core.compatibility import iterable
from sympy.core.exprtools import factor_terms
from sympy.core.relational import Relational, Eq, Ge, Lt
from sympy.sets import Interval
from sympy.sets.sets impo... |
27d45b731ee4f7e2f96b62eaaf80d520e37cfd204dc9a7fec1446d6a2e0455ef | """
This module contain solvers for all kinds of equations:
- algebraic or transcendental, use solve()
- recurrence, use rsolve()
- differential, use dsolve()
- nonlinear (numerically), use nsolve()
(you will need a good starting point)
"""
from sympy import divisors, binomial, expand_func
f... |
125b7cab1477fa0901681cd031d9cd8b30882465b3e85a56ba9585313f42c370 | from sympy import Order, S, log, limit, lcm_list, im, re, Dummy
from sympy.core import Add, Mul, Pow
from sympy.core.basic import Basic
from sympy.core.compatibility import iterable
from sympy.core.expr import AtomicExpr, Expr
from sympy.core.function import expand_mul
from sympy.core.numbers import _sympifyit, oo
from... |
cb53b82ad984aa09934edfa2044d7e26a9f507a4ed59cb19979d31434af9427d | from sympy.tensor import Indexed
from sympy import Integral, Dummy, sympify, Tuple
class IndexedIntegral(Integral):
"""
Experimental class to test integration by indexed variables.
Usage is analogue to ``Integral``, it simply adds awareness of
integration over indices.
Contraction of non-identic... |
d6b3a9921058d13b3a5171efaa34567e10ce2f0221951c83af4caf2e7414c18e | """ Generic SymPy-Independent Strategies """
from sympy.core.compatibility import get_function_name
identity = lambda x: x
def exhaust(rule):
""" Apply a rule repeatedly until it has no effect """
def exhaustive_rl(expr):
new, old = rule(expr), expr
while new != old:
new, old = rul... |
1e1ed6be8c816053f910f8055fe5ed2e445fedf8ac067a1b31de13e8baecc02a | from functools import partial
from sympy.strategies import chain, minimize
import sympy.strategies.branch as branch
from sympy.strategies.branch import yieldify
identity = lambda x: x
def treeapply(tree, join, leaf=identity):
""" Apply functions onto recursive containers (tree)
join - a dictionary mapping co... |
02d0ea37d52030f3e60fbd8e3a296de3f14ad6e43ffa1167feff7c68785636d3 | from . import rl
from .core import do_one, exhaust, switch
from .traverse import top_down
def subs(d, **kwargs):
""" Full simultaneous exact substitution
Examples
========
>>> from sympy.strategies.tools import subs
>>> from sympy import Basic
>>> mapping = {1: 4, 4: 1, Basic(5): Basic(6, 7)}... |
3e1c3f1edbf42774ed9ae9bb9735f766a712de69cbc05db2e934161a7325ddc0 | """ Generic Rules for SymPy
This file assumes knowledge of Basic and little else.
"""
from sympy.utilities.iterables import sift
from .util import new
# Functions that create rules
def rm_id(isid, new=new):
""" Create a rule to remove identities
isid - fn :: x -> Bool --- whether or not this element is an ... |
0e13e7049e51c3fc73846881b527224f257e1f6ce19718236158eb347fa02f29 | """Strategies to Traverse a Tree."""
from sympy.strategies.util import basic_fns
from sympy.strategies.core import chain, do_one
def top_down(rule, fns=basic_fns):
"""Apply a rule down a tree running it on the top nodes first."""
return chain(rule, lambda expr: sall(top_down(rule, fns), fns)(expr))
def bott... |
d0e6d9fa0d43122d60d3b005fabe93f35978a2f1b05bb1ea713ae39243aa8034 | from sympy import Basic
new = Basic.__new__
def assoc(d, k, v):
d = d.copy()
d[k] = v
return d
basic_fns = {'op': type,
'new': Basic.__new__,
'leaf': lambda x: not isinstance(x, Basic) or x.is_Atom,
'children': lambda x: x.args}
expr_fns = assoc(basic_fns, 'new', l... |
81c2ee6523a14b167fb3fd56f704089ee5baacba2e8d5196cb103ae97eaf911c | """
This module provides convenient functions to transform sympy expressions to
lambda functions which can be used to calculate numerical values very fast.
"""
from typing import Any, Dict, Iterable
import inspect
import keyword
import textwrap
import linecache
from sympy.utilities.exceptions import SymPyDeprecation... |
a53ba351df1b9660ac721ffc99f61a04975b9ee024eb120a5f519c84e63cbaa9 | from collections import defaultdict, OrderedDict
from itertools import (
combinations, combinations_with_replacement, permutations,
product, product as cartes
)
import random
from operator import gt
from sympy.core import Basic
# this is the logical location of these functions
from sympy.core.compatibility im... |
5359449d9fa55e2073811b9613b9650fed082e07901a1adcae6351f1c89be9c9 | """
This is a shim file to provide backwards compatibility (cxxcode.py was renamed
to cxx.py in SymPy 1.7).
"""
from sympy.utilities.exceptions import SymPyDeprecationWarning
SymPyDeprecationWarning(
feature="importing from sympy.printing.cxxcode",
useinstead="Import from sympy.printing.cxx",
issue=20256,... |
4a4d988f93d7e42793ea8df31f1f99542d6425303b610333c17a632709547ae7 | """A module providing information about the necessity of brackets"""
from sympy.core.function import _coeff_isneg
# 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": ... |
a6d9f063126be68c772c6e130836d1220c6c0a291a56f1335816aa2292135177 | from sympy.printing.mathml import mathml
from sympy.utilities.mathml import c2p
import tempfile
import subprocess
def print_gtk(x, start_viewer=True):
"""Print to Gtkmathview, a gtk widget capable of rendering MathML.
Needs libgtkmathview-bin"""
with tempfile.NamedTemporaryFile('w') as file:
file... |
5bc85f19902188d42d8dc16766e92de828c8b07056502212bde859aadb9effcc | """
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... |
d5abad2058348a36008c41c78a7dd78c4addbbcb434c56bb31355fc6ceee9b5b | """
A Printer for generating readable representation of most sympy classes.
"""
from typing import Any, Dict
from sympy.core import S, Rational, Pow, Basic, Mul, Number
from sympy.core.mul import _keep_coeff
from .printer import Printer, print_function
from sympy.printing.precedence import precedence, PRECEDENCE
fro... |
1b1105d5621f94f3528653ab65cf0065c87623a1b10e56e92261ea5fad7f3f9a | def pprint_nodes(subtrees):
"""
Prettyprints systems of nodes.
Examples
========
>>> from sympy.printing.tree import pprint_nodes
>>> print(pprint_nodes(["a", "b1\\nb2", "c"]))
+-a
+-b1
| b2
+-c
"""
def indent(s, type=1):
x = s.split("\n")
r = "+-%s\n" ... |
7667356eadb26d9f12aa8ea8875ab411fa95b54016d741f82bf7a12e2827b5a0 | """
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 ... |
13ad35f79d34139f8dd984ed7c3b6fc764a631493817e041242011d9b230b4ed | """
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... |
87f685c022e66623460379d2592826df4c8b0fd146e255692247df5bc1dc0a6b | '''
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 import S, IndexedBase
from sympy.utilities.decorator import doctes... |
92660d821a3ff9220ca9bd043b0e90ca4630395cbf8e3760bab2bf272d3e71fd | """
A few practical conventions common to all printers.
"""
import re
from sympy.core.compatibility import Iterable
from sympy import Derivative
_name_with_digits_p = re.compile(r'^([a-zA-Z]+)([0-9]+)$')
def split_super_sub(text):
"""Split a symbol name into a name, superscripts and subscripts
The first p... |
8e7eb188f89152bd63e88a65e06d76d41e26b0b1e4e9df569746680fc178dbb9 | """
A Printer which converts an expression into its LaTeX equivalent.
"""
from typing import Any, Dict
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 _coeff_isneg, AppliedU... |
0da82ef731f8bba722e818a5fd0144d60b4c3433b29b085cff3d9c256e38f143 | """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... |
27dc6e30be2b6370cd1eece613d2cc7aae83e2bbe428f8569882ba3cfb9b7f9a | from sympy.core.containers import Tuple
from types import FunctionType
class TableForm:
r"""
Create a nice table representation of data.
Examples
========
>>> from sympy import TableForm
>>> t = TableForm([[5, 7], [4, 2], [10, 3]])
>>> print(t)
5 7
4 2
10 3
You can us... |
b1d1f05f9d617f22ecc79254ccc8b7d1b06f6e1c1f8c62d34e38ebc1f6858667 | """
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... |
7a26db2a5cd10577fbe4e1bb04202e46545654d23dcdd57393af4fff8a7d9a0d | from .pycode import (
PythonCodePrinter,
MpmathPrinter, # MpmathPrinter is imported for backward compatibility
NumPyPrinter # NumPyPrinter is imported for backward compatibility
)
from sympy.utilities import default_sort_key
__all__ = [
'PythonCodePrinter',
'MpmathPrinter',
'NumPyPrinter',
... |
b446d20e585feb73df58019aa6d696abfc62d6fe5ab2a73a72dd820b2a82ccc8 | """
Mathematica code printer
"""
from typing import Any, Dict, Set, Tuple
from sympy.core import Basic, Expr, Float
from sympy.printing.codeprinter import CodePrinter
from sympy.printing.precedence import precedence
# Used in MCodePrinter._print_Function(self)
known_functions = {
"exp": [(lambda x: True, "Exp")... |
4c4d60548399b611a0a8fafcf738e5d0db6fb629d78253cd25a227b2c8e67c28 | """
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 "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.