hash
stringlengths
64
64
content
stringlengths
0
1.51M
fd5f40722d7911731f9c9e4adcf278fab1e9a3831e3f761278354b18ef613d88
from sympy.physics.units.systems.mks import MKS from sympy.physics.units.systems.mksa import MKSA from sympy.physics.units.systems.natural import _natural_dim, natural from sympy.physics.units.systems.si import SI
80708103d680437d66987a9483d2c1f18477025ab69fcc2af511186eaf8622fc
import time from sympy import S from sympy.core.numbers import pi from sympy.physics.units import DimensionSystem, hertz, kilogram from sympy.physics.units.definitions import ( G, Hz, J, N, Pa, W, c, g, kg, m, s, meter, gram, second, newton, joule, watt, pascal) from sympy.physics.units.definitions.dimension...
a343c2699485be30f4eccfefcf74f4bdaa5425c3d34873ce065b4d1e661210fa
from sympy import sqrt, S from sympy.physics.units import UnitSystem, centimeter, gram, second, coulomb, charge, speed_of_light, current, mass, \ length, voltage, magnetic_density, magnetic_flux from sympy.physics.units.definitions import coulombs_constant from sympy.physics.units.definitions.unit_definitions impor...
c11d898f90cf03ef397aef52b8a1a53c4722835a61cf1f51091be2fc60bb477a
""" SI unit system. Based on MKSA, which stands for "meter, kilogram, second, ampere". Added kelvin, candela and mole. """ from __future__ import division from sympy.physics.units import DimensionSystem, Dimension, dHg0 from sympy import Rational, pi, sqrt, S from sympy.physics.units.definitions.dimension_definitio...
a5a363ce4f5db38363186f39b00b6a5029ac47ea93905567c416a0fa887a6a8c
from sympy import (Abs, Add, Basic, Function, Number, Rational, S, Symbol, diff, exp, integrate, log, sin, sqrt, symbols, Matrix) from sympy.physics.units import (amount_of_substance, convert_to, find_unit, volume, kilometer) from sympy.physics.units.definitions impor...
167759c2b48b8cce7173cd8f34b63a84550bb0617f6059d30d15f174849c24c9
from sympy.physics.units import DimensionSystem, joule, second, ampere, electronvolt, convert_to, coulomb from sympy.physics.units.systems import cgs from sympy.utilities.pytest import warns_deprecated_sympy from sympy import Rational, S from sympy.physics.units.definitions import c, kg, m, s from sympy.physics.units....
6726c32fb318ea76efc2f35a86bf5050aa573a8813b3500c892f295cc83363ea
from sympy.physics.units.systems.si import dimsys_SI from sympy.utilities.pytest import warns_deprecated_sympy from sympy import S, Symbol, sqrt from sympy.physics.units.dimensions import Dimension from sympy.physics.units.definitions.dimension_definitions import ( length, time ) from sympy.physics.units import fo...
68df06baf2f117068f928e91a79a69d3bb3aac05c327241e90b4cf37d0fbafa6
from sympy import symbols, log, Mul, Symbol, S, Rational from sympy.physics.units import Quantity, Dimension, length, meter from sympy.physics.units.prefixes import PREFIXES, Prefix, prefix_unit, kilo, \ kibi from sympy.physics.units.systems import SI x = Symbol('x') def test_prefix_operations(): m = PREFIXE...
6ac0f394c6f1ec8c2101281fe25071fdb3ba3b96430e9400ae8ee613d36d0d33
from sympy.physics.units.systems.si import dimsys_SI from sympy.utilities.pytest import warns_deprecated_sympy from sympy import (Add, Mul, Pow, Tuple, pi, sin, sqrt, sstr, sympify, symbols) from sympy.physics.units import ( G, centimeter, coulomb, day, degree, gram, hbar, hour, inch, joule, kelvin, kilogr...
e9cd925f9a53501204561457420d8a24b692a14e9b90a57d38aaaf70713863a4
from sympy.physics.units.systems import SI from sympy.utilities.pytest import warns_deprecated_sympy from sympy import Matrix, eye, symbols from sympy.physics.units.definitions.dimension_definitions import ( action, current, length, mass, time, velocity) from sympy.physics.units.dimensions import DimensionSyst...
4bd60a460ae62bc752c28a886a4485a0cd72a0a12855de483199578de5fa82ab
from sympy.concrete.tests.test_sums_products import NS from sympy import sqrt, S from sympy.physics.units import convert_to, coulomb_constant, elementary_charge, gravitational_constant, planck, \ atomic_mass_unit, electronvolt, avogadro_number from sympy.physics.units.definitions.unit_definitions import statcoulom...
d70d2178cde9bfbefab6dc039e3ec940e6f8744c7b71edbedbc90dfabd3175f1
from __future__ import print_function, division from sympy import Basic from sympy import S from sympy.core.expr import Expr from sympy.core.numbers import Integer from sympy.core.sympify import sympify from sympy.core.compatibility import SYMPY_INTS, Iterable import itertools class NDimArray(object): """ E...
b646f00d5d62cb8f5d8ab53954ba4c3a54e5a3e251700354c5215fa2bf595af8
from functools import wraps from sympy import Matrix, eye, Integer, expand, Indexed, Sum from sympy.combinatorics import Permutation from sympy.core import S, Rational, Symbol, Basic, Add from sympy.core.containers import Tuple from sympy.core.symbol import symbols from sympy.functions.elementary.miscellaneous import ...
bb5dfc9f8c82eb0931aa91e80aeba1c2caba7162e86dc51d54636ad7a5540c0a
from sympy.core import symbols, Symbol, Tuple, oo, Dummy from sympy.core.compatibility import iterable, range from sympy.tensor.indexed import IndexException from sympy.utilities.pytest import raises, XFAIL # import test: from sympy import IndexedBase, Idx, Indexed, S, sin, cos, exp, log, Sum, Piecewise, And, Order, L...
215ca75890611e52c0fd4fa5092d265f0c2550fb80255b6f0dcfec0449320bee
import random from sympy import ( Abs, Add, E, Float, I, Integer, Max, Min, N, Poly, Pow, PurePoly, Rational, S, Symbol, cos, exp, log, expand_mul, oo, pi, signsimp, simplify, sin, sqrt, symbols, sympify, trigsimp, tan, sstr, diff, Function) from sympy.matrices.matrices import (ShapeError, MatrixError, ...
f266d28e76fb8238c28bee208d6b135a204f6f5b10c9476e548a06b57a9ffd56
from sympy.matrices.expressions import MatrixExpr from sympy import MatrixBase, Dummy, Lambda, Function, FunctionClass class ElementwiseApplyFunction(MatrixExpr): r""" Apply function to a matrix elementwise without evaluating. Examples ======== It can be created by calling ``.applyfunc(<function...
a473aa9cffe85991bbb0bf0c38502cfc385cc09a0944655ba524da1540e7a494
""" A module which handles Matrix Expressions """ from .slice import MatrixSlice from .blockmatrix import BlockMatrix, BlockDiagMatrix, block_collapse, blockcut from .funcmatrix import FunctionMatrix from .inverse import Inverse from .matadd import MatAdd from .matexpr import (Identity, MatrixExpr, MatrixSymbol, ZeroM...
dc21b2c4e09db14379431cc079182ee0f108b037a59e758d52ee7f35543c33ce
from sympy import (S, Dummy, Lambda, symbols, Interval, Intersection, Set, EmptySet, FiniteSet, Union, ComplexRegion, ProductSet) from sympy.multipledispatch import dispatch from sympy.sets.conditionset import ConditionSet from sympy.sets.fancysets import (Integers, Naturals, Reals, Range, ImageS...
ccbbb298d2330436d9af84e7bc3928eebf40184a52078e27c7549ab85daf6936
from sympy import (Interval, Intersection, Set, EmptySet, S, sympify, FiniteSet, Union, ComplexRegion, ProductSet) from sympy.multipledispatch import dispatch from sympy.sets.fancysets import Integers from sympy.sets.sets import UniversalSet @dispatch(Integers, Set) def union_sets(a, b): inters...
d2c7f5284b484f3d2f852c085cab5e0226ed3fac923567334ebf14662867be92
from sympy import Set, symbols, exp, log, S, Wild, Dummy, oo from sympy.core import Expr, Add from sympy.core.function import Lambda, _coeff_isneg, FunctionClass from sympy.core.mod import Mod from sympy.logic.boolalg import true from sympy.multipledispatch import dispatch from sympy.sets import (imageset, Interval, Fi...
786c112697071b876782f665c11359615242b64aa7c22ddb409e354599024bf8
from sympy.core.expr import unchanged from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.sets.contains import Contains from sympy.sets.fancysets import Interval from sympy.sets.powerset import PowerSet from sympy.sets.sets import FiniteSet from sympy.utilities.pytest import raises, XFAIL...
9f5313de08e52d8ed2d69de03e3341abd4325491ef0d3f322536cde631a29443
from sympy.core.compatibility import range, PY3 from sympy.core.expr import unchanged from sympy.sets.fancysets import (ImageSet, Range, normalize_theta_set, ComplexRegion) from sympy.sets.sets import (FiniteSet, Interval, imageset, Union, Intersection, Pro...
89e9ae62de936feee91521b5ee098b2c3312d0debdbd813f66d38af64d748776
from sympy import (Symbol, Set, Union, Interval, oo, S, sympify, nan, Max, Min, Float, FiniteSet, Intersection, imageset, I, true, false, ProductSet, sqrt, Complement, EmptySet, sin, cos, Lambda, ImageSet, pi, Pow, Contains, Sum, rootof, SymmetricDifference, Piecewise, Matrix, Range, Add, symbols, z...
ec50afd7d339793febbab3d86584378621f6a54bf243113decf43765a5f86967
import warnings from sympy import (plot_implicit, cos, Symbol, symbols, Eq, sin, re, And, Or, exp, I, tan, pi) from sympy.plotting.plot import unset_show from tempfile import NamedTemporaryFile, mkdtemp from sympy.utilities.pytest import skip, warns from sympy.external import import_module from sympy...
2e8453d7beb1f2a1d7593d72ca3f49715cde8132fb636d0e8cea7a4f3af960a0
""" Interval Arithmetic for plotting. This module does not implement interval arithmetic accurately and hence cannot be used for purposes other than plotting. If you want to use interval arithmetic, use mpmath's interval arithmetic. The module implements interval arithmetic using numpy and python floating points. The ...
61940fe3b218af16f1c06741732771c980122198cb17acfce02103133f567964
#!/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...
66cf5109d02daf6b368a784dbc0510bad52101d98b4b52044320a7967f79fa3c
#!/usr/bin/env python """ Program to test that all methods/functions have at least one example doctest. Also checks if docstrings are imported into Sphinx. For this to work, the Sphinx docs need to be built first. Use "cd doc; make html" to build the Sphinx docs. Usage: ./bin/coverage_doctest.py sympy/core or ./...
eeb47a8b1bd70a99d85d59a6b5a6e55f7972f4083f72c0856c8d448176f67efe
#!/usr/bin/env python DESCRIPTION = """ Runs all the examples for testing purposes and reports successes and failures to stderr. An example is marked successful if the running thread does not throw an exception, for threaded examples, such as plotting, one needs to check the stderr messages as well. """ EPILOG = """...
27b961c18920c88ccda07aa31501be4973031bf7e53508aaeea8791d6a5600cd
""" 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...
5f414c6f1415230bbc13b42fbb07290a68d4186ab3e05c103254fd1c87d3393b
#!/usr/bin/env python """Pi digits example Example shows arbitrary precision using mpmath with the computation of the digits of pi. """ from mpmath import libmp, pi import math from sympy.core.compatibility import clock import sys def display_fraction(digits, *, skip=0, colwidth=10, columns=5): """Pretty prin...
42c79fe58aae48fb2a1f00636c32d92d33dfc2e1169ef70778daf3db96237339
#!/usr/bin/env python """ This example shows how to work with coordinate transformations, curvilinear coordinates and a little bit with differential geometry. It takes polar, cylindrical, spherical, rotating disk coordinates and others and calculates all kinds of interesting properties, like Jacobian, metric tensor, ...
ebf2f93738de552d503086dd72142a129e7dc86ee0718b30610eec463f208482
#!/usr/bin/env python """ This example calculates the Ricci tensor from the metric and does this on the example of Schwarzschild solution. If you want to derive this by hand, follow the wiki page here: https://en.wikipedia.org/wiki/Deriving_the_Schwarzschild_solution Also read the above wiki and follow the referenc...
a25b04b10047522b75e108146d46333032c7941aff113a6661b4dfbf54afa099
#!/usr/bin/env python """Precision Example Demonstrates SymPy's arbitrary integer precision abilities """ import sympy from sympy import Mul, Pow, S def main(): x = Pow(2, 50, evaluate=False) y = Pow(10, -50, evaluate=False) # A large, unevaluated expression m = Mul(x, y, evaluate=False) # Eval...
659bcbe2866485a51776cd6091e5e8c021665d510c7b298e9dc96be88bb0d753
#!/usr/bin/env python """Vandermonde matrix example Demonstrates matrix computations using the Vandermonde matrix. * https://en.wikipedia.org/wiki/Vandermonde_matrix """ from sympy import Matrix, pprint, Rational, symbols, Symbol, zeros def symbol_gen(sym_str): """Symbol generator Generates sym_str_n wh...
b3fb7692b30dc02d5b47fe162fcbb1d13530800884a238060cd93a577b69d6a6
#!/usr/bin/env python """ Calculates the Coupled-Cluster energy- and amplitude equations See 'An Introduction to Coupled Cluster Theory' by T. Daniel Crawford and Henry F. Schaefer III. Other Resource : http://vergil.chemistry.gatech.edu/notes/sahan-cc-2010.pdf """ from sympy.physics.secondquant import (AntiSymmetri...
fd429af2b92b98d6812347f57080f533960f1ef7a748635e169182d18ec1e6fa
#!/usr/bin/env python """Matplotlib 2D plotting example Demonstrates plotting with matplotlib. """ import sys from sample import sample from sympy import sqrt, Symbol from sympy.core.compatibility import is_sequence from sympy.external import import_module def mplot2d(f, var, *, show=True): """ Plot a 2d...
ff8010c43e90e2d4393a74c4e55f7cc86dcf230eca1a238fad903bb53f7bec61
#!/usr/bin/env python """ Applying perturbation theory to calculate the ground state energy of the infinite 1D box of width ``a`` with a perturbation which is linear in ``x``, up to second order in perturbation """ from sympy.core import pi from sympy import Integral, var, S from sympy.functions import sin, sqrt de...
9be45488890f307a7ad66f568f25b98292af940df2f632452403e8eec223173c
r""" Utility functions for plotting sympy functions. See examples\mplot2d.py and examples\mplot3d.py for usable 2d and 3d graphing functions using matplotlib. """ from sympy.core.sympify import sympify, SympifyError from sympy.external import import_module np = import_module('numpy') def sample2d(f, x_args): r""...
f5e49637d6f66f5fcb30cf7cb14c69b14e07f390c7f6b68f801071a5bab51838
#!/usr/bin/env python """Matplotlib 3D plotting example Demonstrates plotting with matplotlib. """ import sys from sample import sample from sympy import Symbol from sympy.external import import_module def mplot3d(f, var1, var2, *, show=True): """ Plot a 3d function using matplotlib/Tk. """ impo...
a06c7cf3c0a7ee53f348e583297f9d0b343a69148d2c2584c24322fd34469925
""" Extract reference documentation from the NumPy source tree. """ from __future__ import division, absolute_import, print_function import inspect import textwrap import re import pydoc from collections.abc import Mapping import sys class Reader(object): """ A line-based string reader. """ def __ini...
a0a30dbf2c8abd4d0006006ddfe9dc499f41af7950f904868c8ef0ac50c743b3
""" SymPy statistics module Introduces a random variable type into the SymPy language. Random variables may be declared using prebuilt functions such as Normal, Exponential, Coin, Die, etc... or built with functions like FiniteRV. Queries on random expressions can be made using the functions ======================...
b14fb485fd6a31dcf6d65f06c5e4f4fef80dc2832d0660c4cf0932a2e7c983ec
from __future__ import print_function, division from sympy.sets import FiniteSet from sympy import sqrt, log, exp, FallingFactorial, Rational, Eq, Dummy, piecewise_fold, solveset from .rv import (probability, expectation, density, where, given, pspace, cdf, characteristic_function, sample, sample_iter,...
19f87ff9a18bdbca4bff2b3504ed351e73b97ca47251af4d25eb1436391e2451
from sympy.core.compatibility import as_int, is_sequence from sympy.core.numbers import oo from sympy.core.relational import Eq from sympy.core.symbol import symbols from sympy.polys.domains import FiniteField, QQ, RationalField, FF from sympy.solvers.solvers import solve from .factor_ import divisors from .residue_nth...
802a58e58db96869829c21d76252d54de33805a9dffb99d10014d722d3dff719
""" Number theory module (primes, etc) """ from .generate import nextprime, prevprime, prime, primepi, primerange, \ randprime, Sieve, sieve, primorial, cycle_length, composite, compositepi from .primetest import isprime, is_gaussian_prime from .factor_ import divisors, proper_divisors, factorint, multiplicity, \ ...
6e7a3ba7edfd8bbe9d7b2434d5055e52b45b8e4de5b9d5798a40daa2cab72bc1
from __future__ import print_function, division from collections import defaultdict from sympy.core.compatibility import as_int from sympy.utilities.iterables import multiset, is_palindromic as _palindromic def digits(n, b=10, digits=None): """ Return a list of the digits of ``n`` in base ``b``. The first ...
d716785f0c032d5de417320884c3ea088b239845627cb2353313311491e7d70b
""" Primality testing """ from __future__ import print_function, division from sympy.core.compatibility import as_int from mpmath.libmp import bitcount as _bitlength def _int_tuple(*i): return tuple(int(_) for _ in i) def is_euler_pseudoprime(n, b): """Returns True if n is prime or an Euler pseudoprime ...
61e3c143dd8e7e415a11de8aca5b2aba19acc9e8b213c339799c558d8008338f
""" Integer factorization """ from __future__ import print_function, division from collections import defaultdict import random import math from sympy.core import sympify from sympy.core.compatibility import as_int, SYMPY_INTS from sympy.core.containers import Dict from sympy.core.evalf import bitcount from sympy.cor...
b0371bebee480e84aacb51d527b52d100e0abc4a1be6c39bcd635548eb35910b
from __future__ import print_function, division 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.numb...
e63b65dee809a347f6838b4109df340a8dffce8e16a6f9ef8b7ffaaaa556750e
""" 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...
407ec29cb5a26cebe0cff5ecea49ff6d6d724e2718a73a5999e72aed4b50fbff
"""Formal Power Series""" from __future__ import print_function, division 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 ...
eeccdeb5eb3aae878678cdb3a207437380e5571dd6fcad6acd9dfe9ac3aa562b
from __future__ import print_function, division 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, SY...
9fca3889311b57fc0acbf7c23ea40cc769cd8cb977404eb722616db5c036de29
""" Implementation of the trigsimp algorithm by Fu et al. The idea behind the ``fu`` algorithm is to use a sequence of rules, applied in what is heuristically known to be a smart order, to select a simpler expression that is equivalent to the input. There are transform rules in which a single rule is applied to the e...
b44294157e13431fcf5ebd65c6f90f520fcbea5dc17ec4a5bfadad0bc278bf17
# References : # http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/ # https://en.wikipedia.org/wiki/Quaternion from sympy import S, Rational from sympy import re, im, conjugate, sign from sympy import sqrt, sin, cos, acos, exp, ln from sympy import trigsimp from sympy import integrate from sympy...
f9f7018963020c035bb09692164ddd4f406f5fc60f728c148bd2878dbe30a934
from __future__ import print_function, division from typing import Any, Set from itertools import permutations from sympy.combinatorics import Permutation from sympy.core import AtomicExpr, Basic, Expr, Dummy, Function, sympify, diff, Pow, Mul, Add, symbols, Tuple from sympy.core.compatibility import reduce from sym...
e29e76450ca7582a10e9d7d354f4970f7dcea84b95573a8511f84f8ee4532b85
from sympy.printing.pycode import PythonCodePrinter """ This module collects utilities for rendering Python code. """ def render_as_module(content, standard='python3'): """Renders python code as a module (with the required imports) Parameters ========== standard See the parameter ``standard...
1d777024bd551b046f43bd2287818a77f44111204144330f68323a846f70bc85
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...
da1d434359cb34b192c2945d3216049eae45c0a72a6988d2087270053e3c81b0
from itertools import chain from sympy.codegen.fnodes import Module from sympy.core.symbol import Dummy from sympy.printing.fcode import FCodePrinter """ This module collects utilities for rendering Fortran code. """ def render_as_module(definitions, name, declarations=(), printer_settings=None): """ Creates a `...
98512369dc78297d1195e2efa6ee849c618147f96bdc2a077a81816c59bb81d9
""" 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 ...
5ee325b14603fd8e683894002cc827a3a6ffc1cdbd555b315ad5373f9abb4009
from typing import Dict, Callable from sympy.core import S, Add, Expr, Basic, Mul from sympy.logic.boolalg import Boolean from sympy.assumptions import Q, ask # type: ignore def refine(expr, assumptions=True): """ Simplify an expression using assumptions. Gives the form of expr that would be obtained i...
ee153d0521388a4bd472009b74a41b3156c4700f807fd520aa6dbbe0f6d5855f
"""Module for querying SymPy objects about assumptions.""" from sympy.assumptions.assume import (global_assumptions, Predicate, AppliedPredicate) from sympy.core import sympify from sympy.core.cache import cacheit from sympy.core.relational import Relational from sympy.logic.boolalg import (to_cnf, And, Not, O...
11d04c6ac4c180079a570f0a817e3f2db6a2da9f341bd6a099fc99027e7cda68
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 fact_registry from sympy.core import oo from sympy.logic.inference import satisfiable from sympy.assumptions.cnf...
58c5d7826f2f8d1b45cbd2bc83fbf2034531427c814023da75e5f0b9066e2655
import inspect from sympy.core.cache import cacheit from sympy.core.singleton import S from sympy.core.sympify import _sympify from sympy.logic.boolalg import Boolean from sympy.utilities.source import get_class from contextlib import contextmanager class AssumptionsContext(set): """Set representing assumptions. ...
0f40e28b648cbacb094f64e522e4e860d081bbb84548b6a29654fabdfb5c629f
""" 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...
19b101847c8a180c8687c41d7625c620ce671e4c9fe003e5ef02128ea6445c12
from collections import defaultdict from sympy.assumptions.ask import Q from sympy.assumptions.assume import Predicate, AppliedPredicate from sympy.assumptions.cnf import AND, OR, to_NNF from sympy.core import (Add, Mul, Pow, Integer, Number, NumberSymbol,) from sympy.core.compatibility import MutableMapping from symp...
167d6638653abe6c36124a4b74bdf7c599669ce52f53b42690e7dda904229ef8
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...
e5c65fe392b7cb1106db75f0e6b8d3f173ea849296a0d0a18458e6914e51cf42
""" 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...
3d84254bc6d593b8f3eb8b20cc96fda14c4de44e4599194e31d844c08c67d1da
""" 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 __future__ import print_function, division fr...
bb688f57ecd6a985165faace321f8d1639f958cabebfb127b28f87a640c762c7
from sympy import Order, S, log, limit, lcm_list, Abs, 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...
302e8b2f5ae7cc79127771ac05a604d5a9301abf7616c45c9f0ac42367e67484
from __future__ import print_function, division 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...
114fa36c901267752546b8b9720cced636f628d4935f9c71ba252dc1b09c0203
""" 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...
d739a37a287316cdf5ca64eccde48f74592a701a72fb255feacbeb530aba518f
""" A Printer for generating readable representation of most sympy classes. """ from __future__ import print_function, division from typing import Any, Dict from sympy.core import S, Rational, Pow, Basic, Mul from sympy.core.mul import _keep_coeff from .printer import Printer from sympy.printing.precedence import pr...
ba3a5961cd56775abaa6ebe283e5a7337032dbe64210876dd45c3dfa72384f48
""" A Printer which converts an expression into its LaTeX equivalent. """ from __future__ import print_function, division from typing import Any, Dict import itertools from sympy.core import S, Add, Symbol, Mod from sympy.core.alphabets import greeks from sympy.core.containers import Tuple from sympy.core.function ...
ab9fa7266b3cd06b884423015d06133c063a13123649c0b1c63c584872710bad
"""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 be...
5e6483d7037b1f34c7f48774ecb6181bf35b88d2742c67f87ff78617994a5039
""" 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 __future__ import print_function, division from typing import Any, Dict from sympy.core.function import AppliedUndef...
495d573a9c02d97feb1c4557dd49546ebcf72a23f44530523cb1eed0114cb0ef
from __future__ import print_function, division from sympy.concrete.expr_with_limits import AddWithLimits from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.compatibility import is_sequence from sympy.core.containers import Tuple from sympy.core.expr import Expr from sympy.core.function ...
e571b983fe8f5a24ee833220d9a37a55669851a86034adb6525aa672b2699cae
from __future__ import print_function, division 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) from .log...
556430422c40ba9e469dc05ab9977b7664c8c2651b75a67f82fc4be4f4b1c68d
""" This module contains the machinery handling 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, False, None. True is returned if the object has the...
6f97cd11ba7385e6d3629cbf102aabe6432315f65ca3b5c05dc9b854a1615b4d
""" 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...
8a8cc443a2823de461c0deb0e88476db0a21fd5d2748e41b8e230f2dc58e5c82
from __future__ import print_function, division from collections import defaultdict from functools import cmp_to_key from .basic import Basic from .compatibility import reduce, is_sequence from .parameters import global_parameters from .logic import _fuzzy_group, fuzzy_or, fuzzy_not from .singleton import S from .ope...
85c40c582792280b7b590262022be4e14e6ee321c56663b9d11ba7723f965c6e
from __future__ import print_function, division from typing import Tuple as tTuple 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_args, sympify_return...
771fe935bd25528d04683df98e4a39539fd4a85f5edb6c08ff169a0b7fd6ab3e
from __future__ import print_function, division from typing import Dict, Type, Union from sympy.utilities.exceptions import SymPyDeprecationWarning from .add import _unevaluated_Add, Add from .basic import S from .compatibility import ordered from .basic import Basic from .expr import Expr from .evalf import EvalfMix...
9d21b92ba6ebc021996bb92bc2d58cbffface11c7dd52857ab1ac7914cc69ba0
from __future__ import absolute_import, print_function, division import numbers import decimal import fractions import math import re as regex from .containers import Tuple from .sympify import (SympifyError, converter, sympify, _convert_numpy_types, _sympify, _is_numpy_instance) from .singleton...
e33c94956e7c98aa677e8435f7075b0a6f60c1976e5369991d6a43ae1327077d
from __future__ import print_function, division from typing import Tuple from sympy.core.sympify import _sympify, sympify from sympy.core.basic import Basic from sympy.core.cache import cacheit from sympy.core.compatibility import ordered from sympy.core.logic import fuzzy_and from sympy.core.parameters import global...
b84c7e757d29f2c230e0a7002b362e7207ccd2b34935e2278e851e5c67b955bf
from __future__ import print_function, division from sympy.core.numbers import nan from .function import Function class Mod(Function): """Represents a modulo operation on symbolic expressions. Receives two arguments, dividend p and divisor q. The convention used is the same as Python's: the remainder a...
9f35a03ca657b56be36340e16c9b183c5916f30d649ff2143015c49e9ae70790
"""sympify -- convert objects SymPy internal format""" from __future__ import print_function, division from typing import Dict, Type, Callable, Any from inspect import getmro from .compatibility import iterable from .parameters import global_parameters class SympifyError(ValueError): def __init__(self, expr, ...
7c7d8945aafa63ce98ac76101c42a8943b471ae1b24cd24bccc015ba442ed9c5
""" Adaptive numerical evaluation of SymPy expressions, using mpmath for mathematical functions. """ from __future__ import print_function, division 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 mpmat...
0358178324cf5d0d5f73331b7e66b9097a0de69ea477e458383a5c7f4a165e32
""" Caching facility for SymPy """ from __future__ import print_function, division from distutils.version import LooseVersion as V class _cache(list): """ List of cached functions """ def print_cache(self): """print cache info""" for item in self: name = item.__name__ ...
244735f7047c2457ac448db8669ba6d2da69b5c9d4f898be52bf507cc39a17f2
from __future__ import print_function, division from collections import defaultdict from functools import cmp_to_key import operator from .sympify import sympify from .basic import Basic from .singleton import S from .operations import AssocOp from .cache import cacheit from .logic import fuzzy_not, _fuzzy_group from...
5790151d9c718308fe1817d85ed49a080d8c95398e7d593f41bb450aa1f62d87
"""User-friendly public interface to polynomial functions. """ from __future__ import print_function, division 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...
3fe547109b804c7283a8e1c5262a7880419ed6503396c29191f6d24f5491f4b1
"""py.test hacks to support XFAIL/XPASS""" from __future__ import print_function, division import sys import functools import os import contextlib import warnings from sympy.core.compatibility import get_function_name from sympy.utilities.exceptions import SymPyDeprecationWarning ON_TRAVIS = os.getenv('TRAVIS_BUILD...
8d96fe442e3093542a582972b067a42362970faa2d32c9d87d928a0343495568
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...
3a8531f9615c8a26618958639bce6769e7ba5012e611a2dd3821ad7f5dd56ff1
""" 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...
55604f76321460d1c4edf75b61c990c104d87085a938ff6d167f40d2b1820661
def allclose(A, B, rtol=1e-05, atol=1e-08): if len(A) != len(B): return False for x, y in zip(A, B): if abs(x-y) > atol + rtol * max(abs(x), abs(y)): return False return True
3db5355ed974496807ccbfab38e0ea45c7626e6cbd9a4b1d2c1d98462543865c
"""Elliptical geometrical entities. Contains * Ellipse * Circle """ from __future__ import division, print_function 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...
b16a681725a4a7e676f0eaf1049cc2560430f7820ec1024cbaddd73d2424ea61
"""Utility functions for geometrical entities. Contains ======== intersection convex_hull closest_points farthest_points are_coplanar are_similar """ from __future__ import division, print_function from sympy import Function, Symbol, solve, sqrt from sympy.core.compatibility import ( is_sequence, ordered) from s...
d3a6a2f687d61b1c4b0ffe2fe9d446edc638393a3f8f2bcbed11bfa95e931d4b
from __future__ import division, print_function from sympy.core import Expr, S, Symbol, oo, pi, sympify from sympy.core.compatibility import as_int, ordered from sympy.core.symbol import _symbol, Dummy, symbols from sympy.functions.elementary.complexes import sign from sympy.functions.elementary.piecewise import Piece...
82329232e0f22371a5932b268ea18b4341c07fbec104b051ce5338c8c86db765
from __future__ import print_function, division from typing import Any, Dict, Tuple from itertools import product import re from sympy import sympify def mathematica(s, additional_translations=None): ''' Users can add their own translation dictionary. variable-length argument needs '*' character. E...
4c4c2da3e2699a702e16b7d1738272360207ddf2d8d3636b5375da662aedd231
""" This module implements the functionality to take any Python expression as a string and fix all numbers and other things before evaluating it, thus 1/2 returns Integer(1)/Integer(2) We use the ast module for this. It is well documented at docs.python.org. Some tips to understand how this works: use dump() to ge...
600a30baf3788b849282bd12d29759b646a5bdd1dc05d82f714a943dd750e8cb
from typing import Dict, Any import inspect from .dispatcher import Dispatcher, MethodDispatcher, ambiguity_warn # XXX: This parameter to dispatch isn't documented and isn't used anywhere in # sympy. Maybe it should just be removed. global_namespace = dict() # type: Dict[str, Any] def dispatch(*types, **kwargs): ...
d66d08f183ab2ee725f9bb980aec7da1fa91575611f0d14776d776e0fc1c7bb6
""" Boolean algebra module for SymPy """ from __future__ import print_function, division from collections import defaultdict from itertools import chain, combinations, product from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.cache import cacheit from sympy.core.compatibility import ord...