hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
433cd492b67f90dc1b3390eba38b08417fd9fc1597963748f190e2d254560b2a | from sympy import symbols
from sympy.tensor.array.expressions.array_expressions import ZeroArray
from sympy.testing.pytest import raises
def test_zero_array():
assert ZeroArray() == 0
assert ZeroArray().is_Integer
za = ZeroArray(3, 2, 4)
assert za.shape == (3, 2, 4)
za_e = za.as_explicit()
as... |
85fb8873fc929e82cd0b75370787530e159706510ac396d8bd197eb3daec127c | from sympy import MatrixSymbol, symbols, Identity
from sympy.codegen.array_utils import CodegenArrayTensorProduct, CodegenArrayPermuteDims
from sympy.tensor.array.expressions.arrayexpr_derivatives import array_derive
k = symbols("k")
I = Identity(k)
X = MatrixSymbol("X", k, k)
x = MatrixSymbol("x", k, 1)
A = MatrixS... |
7915a5f02a3f695312ef18942b68b0abcb2d7643016da30975b2fc29b149301f | from sympy.assumptions.ask import Q
from sympy.assumptions.refine import refine
from sympy.core.numbers import oo
from sympy.core.relational import Equality, Eq, Ne
from sympy.core.singleton import S
from sympy.core.symbol import (Dummy, symbols)
from sympy.functions import Piecewise
from sympy.functions.elementary.mis... |
71594457c701a1d03c31d0d2f8c96118440d4f7dfacf361fbbbdfb3b5a1e3459 | from sympy import Rational, I, expand_mul, S, simplify, sqrt
from sympy.matrices.matrices import NonSquareMatrixError
from sympy.matrices import Matrix, zeros, eye, SparseMatrix
from sympy.abc import x, y, z
from sympy.testing.pytest import raises
from sympy.testing.matrices import allclose
def test_LUdecomp():
t... |
52a9e85a295bf0f233f11323f9b526cc4eea0e280031c5f2119903585393805b | from sympy.matrices.expressions import MatrixExpr
from sympy import Q
class Factorization(MatrixExpr):
arg = property(lambda self: self.args[0])
shape = property(lambda self: self.arg.shape) # type: ignore
class LofLU(Factorization):
@property
def predicates(self):
return (Q.lower_triangular,... |
6f0c02cf987cc7bd9ff674776d78875d6b862e0eb574427fe2fdd239067eb87f | from sympy.core.expr import unchanged
from sympy.sets import (ConditionSet, Intersection, FiniteSet,
EmptySet, Union, Contains, ImageSet)
from sympy import (Symbol, Eq, Ne, S, Abs, sin, asin, pi, Interval,
And, Mod, oo, Function, Lambda, symbols, Matrix, MatrixSymbol)
from sympy.testing.pytest import raises, wa... |
2d971c13c98a8e09cf93064c7b0b28234dd349e81f3041ac13cd252812d157cb | #!/usr/bin/env python
"""Distutils based setup script for SymPy.
This uses Distutils (https://python.org/sigs/distutils-sig/) the standard
python mechanism for installing packages. Optionally, you can use
Setuptools (https://setuptools.readthedocs.io/en/latest/)
to automatically handle dependencies. For the easiest in... |
8a1170ef671d03018f13b5c73e9c7cb4561fe3255f9773c16e1f5069f155389b | #!/usr/bin/env python
"""
Run tests for specific packages that use optional dependencies.
The optional dependencies need to be installed before running this.
"""
# Add the local sympy to sys.path (needed for CI)
from get_sympy import path_hack
path_hack()
class TestsFailedError(Exception):
pass
print('Testing... |
23abeff7d8e66e9abb6331eae5090933db11acd9d9abd078f8447ca1286ba3f1 | #!/usr/bin/env python
""" Update the ask_generated.py file
This must be run each time known_facts is changed
Should be run from sympy root directory
$ python bin/ask_update.py
"""
# hook in-tree SymPy into Python path, if possible
import os
import sys
isympy_path = os.path.abspath(__file__)
isympy_dir = os.path.d... |
f107212b25a5acfc6fa8f261332cc877327938dfe87c5f8a22ee00d7e7dbf112 | """
SymPy is a Python library for symbolic mathematics. It aims to become a
full-featured computer algebra system (CAS) while keeping the code as simple
as possible in order to be comprehensible and easily extensible. SymPy is
written entirely in Python. It depends on mpmath, and other external libraries
may be option... |
fa19c91743fcff8fdfef0d3b66a769e9a67387844bf540833828fd95edd03037 | 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
... |
57f3ee2c395cc2c27f788a39ff27e8171d116349c44daa4c13477ae46f459cc8 | __version__ = "1.9.dev"
|
149291da1b99e9ff4a7f95dc84b8ff5988098475c3a0ef9c7c28f0865c0d648d | """
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 ``O``, ``S``, ``I``,... |
cc066e437b4fb8e1c534cf1fe53d6438830bba9bcfdb3ede844ddf9775711128 | #
# SymPy documentation build configuration file, created by
# sphinx-quickstart.py on Sat Mar 22 19:34:32 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are... |
4f4f78f6c59ad78a2d6e90a6fc57b280c6b7f2f9167f9b75db3c7b98b1dbee2f | """
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
LogCauchy
L... |
8e2703415495ed0dedd3c9f935e88fe6fc1d067ec3a715d6d16cd5cfccdffbc0 | from __future__ import print_function, division
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,... |
eec6d5bc8d123390661baffce0e7bcd657cc8815baafe3e60324e09f177c6765 | from sympy import S, Basic, exp, multigamma, pi
from sympy.core.sympify import sympify, _sympify
from sympy.matrices import (ImmutableMatrix, Inverse, Trace, Determinant,
MatrixSymbol, MatrixBase, Transpose, MatrixSet,
matrix2numpy)
from sympy.stats.rv import (_va... |
5a3b44adf2ff6b6587eb70e7e44dfc8e1692983adcf2e1eaf94640f70b6fa851 | import itertools
from sympy import (MatrixExpr, Expr, ShapeError, ZeroMatrix,
Add, Mul, MatMul, S, expand as _expand)
from sympy.stats.rv import RandomSymbol, is_random
from sympy.core.sympify import _sympify
from sympy.stats.symbolic_probability import Variance, Covariance, Expectation
class Exp... |
0ce0452f6f466d8a39e201a081a652aa329e97135f5a8d5f4f990c3c59782721 | """
Contains
========
FlorySchulz
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 ... |
0c8026ebbcb743c84fe8053423c7881ce6955a5a5395cda02cedf0629f519dab | 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... |
34fe072665e7a5569da38da9998d4e002baa45e9c5bcf61ee992e1046c40314e | """
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... |
b1a66941e5b49bdca9252b93e1e6b87c617a1fd5739fd2bc1372be4dba551121 | from sympy import (Basic, sympify, symbols, Dummy, Lambda, summation,
Piecewise, S, cacheit, Sum, exp, I, Ne, Eq, poly,
series, factorial, And, floor)
from sympy.polys.polyerrors import PolynomialError
from sympy.stats.crv import reduce_rational_inequalities_wrap
from sympy.stats.... |
51ab2f096371e763ae338ee2a5ea243a72495f92bc94151df26632f14a81d736 | """
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... |
19d062d085a7d3a14680898fd7d5a21e8c052bf9372e7dfa01af1bbec59ca5cf | 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... |
bf6b7b8bf185e168c5c7a3bf91cf64c440fcbcc64fa3cecafc2619319017ac89 | from sympy import Basic
from sympy.stats.joint_rv import ProductPSpace
from sympy.stats.rv import ProductDomain, _symbol_converter, Distribution
class StochasticPSpace(ProductPSpace):
"""
Represents probability space of stochastic processes
and their random variables. Contains mechanics to do
computat... |
f0d7a31e6240f521921e1641f47591bac55435b5dd9ef49b05a53aa31bfbf8a1 | """
Generating and counting primes.
"""
import random
from bisect import bisect
from itertools import count
# Using arrays for sieving instead of lists greatly reduces
# memory consumption
from array import array as _array
from sympy import Function, S
from sympy.core.compatibility import as_int
from .primetest impo... |
c4b80764de5e5da194c37d1310e20c0a07d21d27bf6ea13107276f3b3147b871 | from sympy.core.mul import Mul
from sympy.core.singleton import S
from sympy.concrete.expr_with_intlimits import ExprWithIntLimits
from sympy.core.exprtools import factor_terms
from sympy.functions.elementary.exponential import exp, log
from sympy.polys import quo, roots
from sympy.simplify import powsimp
from sympy.co... |
0a0b2808d6cee6671199b3cbc488e7901159a088c48d60985476e3d985d0e39b | from sympy.calculus.singularities import is_decreasing
from sympy.calculus.util import AccumulationBounds
from sympy.concrete.expr_with_limits import AddWithLimits
from sympy.concrete.expr_with_intlimits import ExprWithIntLimits
from sympy.concrete.gosper import gosper_sum
from sympy.core.add import Add
from sympy.core... |
a8a622283cf0ecd0e32467b96d4a667aa9bc3d18a16de2ae1de96b41a69b82e7 | """
PythonMPQ: Rational number type based on Python integers.
This class is intended as a pure Python fallback for when gmpy2 is not
installed. If gmpy2 is installed then its mpq type will be used instead. The
mpq type is around 20x faster. We could just use the stdlib Fraction class
here but that is slower:
from... |
3be848077e87a1a9ef12d3b2b006d9a1e80424776fb107d0618cac295d4a8e3f | import os
import mpmath.libmp as mlib
from sympy.external import import_module
__all__ = [
# GROUND_TYPES is either 'gmpy' or 'python' depending on which is used. If
# gmpy is installed then it will be used unless the environment variable
# SYMPY_GROUND_TYPES is set to something other than 'auto', 'gmpy'... |
86872904f741e9add7f3686115a3857fabaa06849c524fb7fe481c98a7fcb91a | """
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... |
897a231bb6d3ebd948183a99b0fb9b965922adf7ac65af89db3dfb2b65228ef1 | 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 ... |
a89cf952500226bbe7280af9bd9118a386cf5bd1c955d78e5605dee475a985d6 | 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 ... |
cab5982a15b90e4752cba6bbddc6f8b8d30ceee3e5793fab2d0f9c8832c1bee6 | from collections import defaultdict
from functools import reduce
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 iterable, SYMPY_INTS
from sympy.core.fun... |
cb24db7b8dccf3d4ec445abfe79aa810d0af406ddaa39d3d771d15d84f42de44 | 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... |
0f9c5796687500bc63f52c8275d51d8266a59e2bca0742b20900b3619c9e1e1d | from sympy.core import S, Basic, Dict, Symbol, Tuple, sympify
from sympy.core.compatibility import iterable
from sympy.core.symbol import Str
from sympy.sets import Set, FiniteSet, EmptySet
class Class(Set):
r"""
The base class for any kind of class in the set-theoretic sense.
Explanation
===========... |
b415c17ae57f52c47cb1c3b3fb89a09db3fceaa52fad5b5625d3cd2148f07ba3 | from sympy.tensor.array.expressions.array_expressions import ArrayTensorProduct, ArrayContraction, ArrayAdd, \
ArrayDiagonal
from sympy.tensor.array.expressions.conv_array_to_matrix import convert_array_to_matrix
from sympy.tensor.array.expressions.conv_indexed_to_array import convert_indexed_to_array
from sympy.te... |
4111cc678c42b60b1b41562099e6577e0b500b27f4ae21471f92c434475837ce | """
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... |
1706fbd1638f6a2058f036645cd6f6955dab7d4ed3f9703bba92aa9d4824aa33 | """
The contents of this file are the return value of
``sympy.assumptions.ask.compute_known_facts``.
Do NOT manually edit this file.
Instead, run ./bin/ask_update.py.
"""
from sympy.core.cache import cacheit
from sympy.assumptions.cnf import Literal
from sympy.assumptions.ask import Q
@cacheit
def get_all_known_fact... |
888f2b07056321efda00586380721f0980645940ab98ea86e31e7c9b58578627 | from typing import Dict, Callable
from sympy.core import S, Add, Expr, Basic, Mul
from sympy.logic.boolalg import Boolean
from sympy.assumptions import ask, Q # type: ignore
def refine(expr, assumptions=True):
"""
Simplify an expression using assumptions.
Explanation
===========
Unlike :func:... |
3c54bc7634ea88d6c654c8e0ecf68f8c47f09a3c9955f8a85e2455ceaa80dc4d | """
A module to implement logical predicates and assumption system.
"""
from .assume import (
AppliedPredicate, Predicate, AssumptionsContext, assuming,
global_assumptions
)
from .ask import Q, ask, register_handler, remove_handler
from .refine import refine
from .relation import BinaryRelation, AppliedBinaryR... |
0f210aa2e4011c7cdd883d2cb648a2fc90ec5bf57cba461047d69dcd0ac62952 | """
Functions and wrapper object to call assumption property and predicate
query with same syntax.
In SymPy, there are two assumption systems. Old assumption system is
defined in sympy/core/assumptions, and it can be accessed by attribute
such as ``x.is_even``. New assumption system is definded in
sympy/assumptions, a... |
f318642be315ff0f0352c1ef85ae62a82b28cc49de5b5fe4725b89fd0deb4ba7 | """Module for querying SymPy objects about assumptions."""
from sympy.assumptions.assume import (global_assumptions, Predicate,
AppliedPredicate)
from sympy.assumptions.cnf import CNF, EncodedCNF, Literal
from sympy.core import sympify
from sympy.core.kind import BooleanKind
from sympy.core.relational import E... |
74d4ccb74b7df07b701a7737b4a3747c47a0a88b35f53c97eb990e51be70d1ec | """
Module to evaluate the proposition with assumptions using SAT algorithm.
"""
from sympy import Symbol, S
from sympy.assumptions.ask_generated import get_all_known_facts
from sympy.assumptions.assume import global_assumptions, AppliedPredicate
from sympy.assumptions.sathandlers import class_fact_registry
from sympy... |
7b754cd7fadd68235c6047aad54e81327052c73cf9dd6217c987023f836e1912 | """
Known facts in assumptions module.
This module defines the facts in ``get_known_facts()``, and supports functions
to generate the contents in ``sympy.assumptions.ask_generated`` file.
"""
from sympy.core.cache import cacheit
from sympy.assumptions import Q
from sympy.assumptions.cnf import CNF
from sympy.logic.bo... |
437df5797f39236f05ae3e2020d71183502b55b47b26a4dd59943ca42c39fb8f | """A module which implements predicates and assumption context."""
from contextlib import contextmanager
import inspect
from sympy.core.assumptions import ManagedProperties
from sympy.core.symbol import Str
from sympy.core.sympify import _sympify
from sympy.logic.boolalg import Boolean, false, true
from sympy.multiple... |
69a3a6c8227e4a7f37b779a3c225177eaa8e649780ce131a2faf2f66fca0daed | """
The classes used here are for the internal use of assumptions system
only and should not be used anywhere else as these don't possess the
signatures common to SymPy objects. For general use of logic constructs
please refer to sympy.logic classes And, Or, Not, etc.
"""
from itertools import combinations, product
fro... |
7db11e8cecfec6f48a61aec1e648d87b23f0db4da248e29e2967b25728f00e6c | from collections import defaultdict
from sympy.assumptions.ask import Q
from sympy.core import (Add, Mul, Pow, Number, NumberSymbol, Symbol)
from sympy.core.numbers import ImaginaryUnit
from sympy.functions.elementary.complexes import Abs
from sympy.logic.boolalg import (Equivalent, And, Or, Implies)
from sympy.matric... |
99e717a76001dcda41893e8b6f020030f0c5236d8d0abeba91461398f13984ee | """A functions module, includes all the standard functions.
Combinatorial - factorial, fibonacci, harmonic, bernoulli...
Elementary - hyperbolic, trigonometric, exponential, floor and ceiling, sqrt...
Special - gamma, zeta,spherical harmonics...
"""
from sympy.functions.combinatorial.factorials import (factorial, fac... |
f472476c85b313d0d17047e25b797c4ac639f283676ff9cff3ec2b94abbc45d9 | 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... |
15a3238d6fd662a46b9da917d80969eaa818698261f6a34b88ce95c4b8f47648 | from sympy.core import (Function, Pow, sympify, Expr)
from sympy.core.relational import Relational
from sympy.polys import Poly, decompose
from sympy.utilities.misc import func_name
def decompogen(f, symbol):
"""
Computes General functional decomposition of ``f``.
Given an expression ``f``, returns a list... |
ed1c7df1b49fa905cc592e0af67c02eafaff908f954b0c81f86be749d9f817c6 | """
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... |
0c2e4c196ccbbefbb6731dbe1d93e08ee8a2816553440cb6c5fcec2f6d908b32 | """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... |
93be5e3a84048fef238e29d39f2b033c4572b06a861f4d09dd3ef015a30ee9ba | """
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... |
01c297c1a0a6450b67f79cca81328b73b98ac3de89fdd55b5c6e896032b9f287 | from sympy import Order, S, log, limit, lcm_list, im, re, Dummy, Piecewise
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 _sympify... |
808efb9188d5d6b222c70991881a75a86c603b0ffb0e7f0854fa46483e02b125 | """
module for generating C, C++, Fortran77, Fortran90, Julia, Rust
and Octave/Matlab routines that evaluate sympy expressions.
This module is work in progress.
Only the milestones with a '+' character in the list below have been completed.
--- How is sympy.utilities.codegen different from sympy.printing.ccode? ---
W... |
69e44ef04e875d5436b9e661301da4e4c37f4654d621340b1ddd974b638fbf04 | """
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 builtins
import inspect
import keyword
import textwrap
import linecache
from sympy.utilities.exceptions import ... |
a2b0f5dd41740980b082107d425d52728e5c659a1a80bda5e6b811869916a471 | 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 ... |
f7780de58055842f19daa8247d7217cd1897b03e7445592ba1be03ecf74bafc6 | """
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... |
6805696e719fd0f91ad24e0fd4dd14e159f9afdf267e7101013b3991f1011b16 | """
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... |
483c5cdfedbb29575aaf07b42cb7363d84b54540233f1f7662b366cec1ed0957 | """
A few practical conventions common to all printers.
"""
import re
from collections.abc import Iterable
from sympy 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 first part of... |
192c370562d77fcaa455f85d58bdd566b7c45f5f39d2207dbd904a3e95909eca | """
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... |
8ae2f0818a282097c822d59a8d8ff8e0c94088fdcfa0e24d6bace4577260b733 | from .pycode import (
PythonCodePrinter,
MpmathPrinter, # MpmathPrinter is imported for backward compatibility
)
from .numpy import NumPyPrinter # NumPyPrinter is imported for backward compatibility
from sympy.utilities import default_sort_key
__all__ = [
'PythonCodePrinter',
'MpmathPrinter',
'N... |
94a2d4cb25e811ec3c2df2fe8e04fe995532b5edc1fff113481b9401f9dab33c | from typing import Any, Dict
from sympy.core.compatibility import is_sequence
from sympy.external import import_module
from sympy.printing.printer import Printer
import sympy
from functools import partial
aesara = import_module('aesara')
if aesara:
aes = aesara.scalar
aet = aesara.tensor
from aesara.ten... |
60c2c498079363285f01372a88c74489c7a6ac8a8742568ff1327fa2185d9999 | from distutils.version import LooseVersion as V
from collections.abc import Iterable
from sympy import Mul, S
from sympy.codegen.cfunctions import Sqrt
from sympy.external import import_module
from sympy.printing.precedence import PRECEDENCE
from sympy.printing.pycode import AbstractPythonCodePrinter
import sympy
ten... |
eabe9ac37575c7b692595916cd67e9d49fd699aaf42826b18c7b2027f101e75e | from typing import Any, Dict
from sympy.core.compatibility import is_sequence
from sympy.external import import_module
from sympy.printing.printer import Printer
import sympy
from functools import partial
from sympy.utilities.decorator import doctest_depends_on
from sympy.utilities.exceptions import SymPyDeprecationW... |
0b8346923de88756208138872f30a428ac5897f5cb190344bf50aa7ed8fe49f2 | """ Integral Transforms """
from functools import reduce
from sympy.core import S
from sympy.core.compatibility import iterable, ordered
from sympy.core.function import Function
from sympy.core.relational import _canonical, Ge, Gt
from sympy.core.numbers import oo
from sympy.core.symbol import Dummy
from sympy.integra... |
70433a41fa130b8d0234ee6cf62d733db3d53ee12065a1acb3b842519d49f111 | from typing import Dict, 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, pi, I
f... |
9f92b75b10acd07a122c1f248de8be44b35dc608d86323e729fef70a7a08ac1e | """Base class for all the objects in SymPy"""
from collections import defaultdict
from collections.abc import Mapping
from itertools import chain, zip_longest
from .assumptions import BasicMeta, ManagedProperties
from .cache import cacheit
from .sympify import _sympify, sympify, SympifyError
from .compatibility import... |
19b8abfe228bade9505ae3da8aca9bfc09b63d29a5b414679eb12ae3dec50b9a | from typing import Callable
from math import log as _log
from .sympify import _sympify
from .cache import cacheit
from .singleton import S
from .expr import Expr
from .evalf import PrecisionExhausted
from .function import (_coeff_isneg, expand_complex, expand_multinomial,
expand_mul, _mexpand)
from .logic import f... |
f7e76954493ea43fd4a6d71cdafcde5edd253b92f83ef93b653977c1a27d5dce | """Singleton mechanism"""
from .core import Registry
from .assumptions import ManagedProperties
from .sympify import sympify
class SingletonRegistry(Registry):
"""
The registry for the singleton classes (accessible as ``S``).
Explanation
===========
This class serves as two separate things.
... |
735e9a0098e11097bbd8d4838d69a79afd19ca782a97db84794184ee7719c2bd | """
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... |
c44bad27cd40003771e6dd921d5f5a835da95efde1fd0fc7c2dd3da8a2f54c4c | 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
from .decorators import call_highest_priority, sympify_method_arg... |
5300b896164394a9fcb14fdbadcc6afbc0b3a23c8bb89ced1672fce7a17811b7 | from typing import Dict, Union, Type
from sympy.utilities.exceptions import SymPyDeprecationWarning
from .basic import S, Atom
from .compatibility import ordered
from .basic import Basic
from .evalf import EvalfMixin
from .function import AppliedUndef
from .sympify import _sympify, SympifyError
from .parameters import... |
56623c9080748e7884066852581106c058216926c5721a11ebdf8122b379b815 | import numbers
import decimal
import fractions
import math
import re as regex
import sys
from .containers import Tuple
from .sympify import (SympifyError, converter, sympify, _convert_numpy_types, _sympify,
_is_numpy_instance)
from .singleton import S, Singleton
from .expr import Expr, AtomicExpr... |
fa890e8912f7d3d6e2d32b82a9cd68a601d555212ef2cfe8b21d50f9c4c858af | from operator import attrgetter
from typing import Tuple, Type
from collections import defaultdict
from sympy.utilities.exceptions import SymPyDeprecationWarning
from sympy.core.sympify import _sympify as _sympify_, sympify
from sympy.core.basic import Basic
from sympy.core.cache import cacheit
from sympy.core.compat... |
89107cdcfd966fbe9c16ca5a25e9e8c5a8c3be45c4586c5b9554ac3f10a72f3d | from sympy.core.assumptions import StdFactKB, _assume_defined
from sympy.core.compatibility import is_sequence, ordered
from .basic import Basic, Atom
from .sympify import sympify
from .singleton import S
from .expr import Expr, AtomicExpr
from .cache import cacheit
from .function import FunctionClass
from .kind import... |
37123fc861641d0f6eae6c8722d1249bc84e45aa93e39aa6d2767dfc8ac7f460 | """
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.
"""
import operator
from collections import defaultdict
from time import perf_counter as clock
from sympy.external.gmpy import SYMPY_INTS, HA... |
bd6ebbf5969480f05d252a451fef7ef5d00d045dfe6073054435b167ce609896 | """sympify -- convert objects SymPy internal format"""
import typing
if typing.TYPE_CHECKING:
from typing import Any, Callable, Dict, Type
from inspect import getmro
from .compatibility import iterable
from .parameters import global_parameters
class SympifyError(ValueError):
def __init__(self, expr, base_e... |
892594c52a5393554fc8621174a1c06438191789508358decd88d0200bb69833 | """
Adaptive numerical evaluation of SymPy expressions, using mpmath
for mathematical functions.
"""
from typing import Tuple
import math
import mpmath.libmp as libmp
from mpmath import (
make_mpc, make_mpf, mp, mpc, mpf, nsum, quadts, quadosc, workprec)
from mpmath import inf as mpmath_inf
from mpmath.libmp imp... |
4a69209f5a1ebdb8d34f711d50ebef26b5dd9310ccadc50a9eb0a19af9623d34 | from collections import defaultdict
from functools import cmp_to_key, reduce
import operator
from .sympify import sympify
from .basic import Basic
from .singleton import S
from .operations import AssocOp, AssocOpDispatcher
from .cache import cacheit
from .logic import fuzzy_not, _fuzzy_group
from .expr import Expr
fro... |
9511ea934497f5f0df4cc2783fea551a30000567841024462472289c9e7fe54a | """Tools for setting up interactive sessions. """
from distutils.version import LooseVersion as V
from sympy.interactive.printing import init_printing
preexec_source = """\
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('... |
c34f03d7a04e55712d0ed66d2de13ce96998df9876c5b4d699c54afc10786cfd | """OO layer for several polynomial representations. """
from sympy 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 class for lo... |
e29fe7957497d163cae7b41d1fa1ff48f10a66f4f95b62e894b94909d519f96d | """User-friendly public interface to polynomial functions. """
from functools import wraps, reduce
from operator import mul
from sympy.core import (
S, Basic, Expr, I, Integer, Add, Mul, Dummy, Tuple
)
from sympy.core.basic import preorder_traversal
from sympy.core.compatibility import iterable, ordered
from sym... |
19198ffc6f0b6fa2f28a1a92a8aac2d208f6b0a963ca699aa70e302e854b74d0 | """Algorithms for computing symbolic roots of polynomials. """
import math
from functools import reduce
from sympy.core import S, I, pi
from sympy.core.compatibility import ordered
from sympy.core.exprtools import factor_terms
from sympy.core.function import _mexpand
from sympy.core.logic import fuzzy_not
from sympy... |
cb34651abb2e900afc2da3796db08d26a2c5b4b07cb283811c33365452a5958e | """Sparse polynomial rings. """
from typing import Any, Dict
from operator import add, mul, lt, le, gt, ge
from functools import reduce
from types import GeneratorType
from sympy.core.compatibility import is_sequence
from sympy.core.expr import Expr
from sympy.core.numbers import igcd, oo
from sympy.core.symbol imp... |
a913e1f14ed39320d24446a01a19da552348947ad008a6aacf3fbcb5d8bce453 | """Tools and arithmetics for monomials of distributed polynomials. """
from itertools import combinations_with_replacement, product
from textwrap import dedent
from sympy.core import Mul, S, Tuple, sympify
from sympy.core.compatibility import iterable
from sympy.polys.polyerrors import ExactQuotientFailed
from sympy... |
c27d176ac4239e55983e059ebfa0aa184b5b65ce7ad768640a3ec2c89ea0c4f1 | """Sparse rational function fields. """
from typing import Any, Dict
from functools import reduce
from operator import add, mul, lt, le, gt, ge
from sympy.core.compatibility import is_sequence
from sympy.core.expr import Expr
from sympy.core.mod import Mod
from sympy.core.numbers import Exp1
from sympy.core.singlet... |
34711d751dccbcae7d9085b3968acc2603faf70ccbfd3b781c74f31be5ab309a | """Low-level linear systems solver. """
from sympy.utilities.iterables import connected_components
from sympy.matrices import MutableDenseMatrix
from sympy.polys.domains import EX
from sympy.polys.rings import sring
from sympy.polys.polyerrors import NotInvertible
from sympy.polys.domainmatrix import DomainMatrix
... |
d4c2498430fbc456b0e7b167bbb0bebc46857ac4ac27f9ec29857e80efa2e2f2 | """Real and complex root isolation and refinement algorithms. """
from sympy.polys.densearith import (
dup_neg, dup_rshift, dup_rem)
from sympy.polys.densebasic import (
dup_LC, dup_TC, dup_degree,
dup_strip, dup_reverse,
dup_convert,
dup_terms_gcd)
from sympy.polys.densetools import (
dup_cle... |
389a05bb797d3799fe7d86f3348815a19ddfda5694f462d279890cf8c54adaba | """Useful utilities for higher level polynomial classes. """
from sympy.core import (S, Add, Mul, Pow, Eq, Expr,
expand_mul, expand_multinomial)
from sympy.core.exprtools import decompose_power, decompose_power_rat
from sympy.polys.polyerrors import PolynomialError, GeneratorsError
from sympy.polys.polyoptions im... |
e8de2206168eea48aca7da0133694840e1dfbf735f0c873eb671db0be79d5b61 | """Euclidean algorithms, GCDs, LCMs and polynomial remainder sequences. """
from sympy.ntheory import nextprime
from sympy.polys.densearith import (
dup_sub_mul,
dup_neg, dmp_neg,
dmp_add,
dmp_sub,
dup_mul, dmp_mul,
dmp_pow,
dup_div, dmp_div,
dup_rem,
dup_quo, dmp_quo,
dup_prem... |
3090d232b637cebb4ace093e201022e5fead6d099aa620826c51e0b6a328446d | """Tools for constructing domains for expressions. """
from sympy.core import sympify
from sympy.core.compatibility import ordered
from sympy.core.evalf import pure_complex
from sympy.polys.domains import ZZ, QQ, ZZ_I, QQ_I, EX
from sympy.polys.domains.complexfield import ComplexField
from sympy.polys.domains.realfie... |
a87d4ed83e98efe3a2742c8949c6e6d9f0d709a064e4294b4ff88d0b95fafcee | import re
import fnmatch
# XXX Python 2 unicode import test.
# May remove after deprecating python 2.7.
message_unicode_A = \
"File contains a unicode character : %s, line %s. " \
"But with no encoding header. " \
"See https://www.python.org/dev/peps/pep-0263/ " \
"and add '# coding=utf-8'"
message_un... |
89261d2c6dbd2a0aa0cd90bc2f72a86346d0c0e20b6f8b7118f6ba57c3a1303e | """
This is our testing framework.
Goals:
* it should be compatible with py.test and operate very similarly
(or identically)
* doesn't require any external dependencies
* preferably all the functionality should be in this file only
* no magic, just import the test file and execute the test functions, that's it
* po... |
da8182e570b39c318aab8c8dad80be4d54c295acfec19a3290ebc50f33157ce6 | from sympy import S, simplify
from sympy.core import Basic, diff
from sympy.matrices import Matrix
from sympy.vector import (CoordSys3D, Vector, ParametricRegion,
parametric_region_list, ImplicitRegion)
from sympy.vector.operators import _get_coord_sys_from_expr
from sympy.integrals import Integ... |
60e769daf63f5d942a2bd503ed07df3c556dea3bbede71f36949de07effa6026 | from functools import singledispatch
from sympy import pi, tan
from sympy.simplify import trigsimp
from sympy.core import Basic, Tuple
from sympy.core.symbol import _symbol
from sympy.solvers import solve
from sympy.geometry import Point, Segment, Curve, Ellipse, Polygon
from sympy.vector import ImplicitRegion
class ... |
17a4799090ef5c1f351486b2687b020d697b021fd97c5001ea0778048b026ecb | """Elliptical geometrical entities.
Contains
* Ellipse
* Circle
"""
from sympy import Expr, Eq
from sympy.core import S, pi, sympify
from sympy.core.parameters import global_parameters
from sympy.core.logic import fuzzy_bool
from sympy.core.numbers import Rational, oo
from sympy.core.compatibility import ordered
fro... |
d96f485b0e19b48a15e267c17a2cc13b63a390bb3a43aa92283b4882f3beb92f | """Transform a string with Python-like source code into SymPy expression. """
from tokenize import (generate_tokens, untokenize, TokenError,
NUMBER, STRING, NAME, OP, ENDMARKER, ERRORTOKEN, NEWLINE)
from keyword import iskeyword
import ast
import unicodedata
from io import StringIO
from sympy.assumptions.ask im... |
cd40a07dccc2bc7b9ca48c9e220d67e85db65bdabbdfbd70c8ea4237c07b8edf | """
This module implements Pauli algebra by subclassing Symbol. Only algebraic
properties of Pauli matrices are used (we don't use the Matrix class).
See the documentation to the class Pauli for examples.
References
==========
.. [1] https://en.wikipedia.org/wiki/Pauli_matrices
"""
from sympy import Symbol, I, Mul,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.