Skip to content

Commit

Permalink
Merge 163b00e into 7a14571
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed May 29, 2015
2 parents 7a14571 + 163b00e commit 023b144
Show file tree
Hide file tree
Showing 92 changed files with 1,244 additions and 2,750 deletions.
1 change: 0 additions & 1 deletion doc/modules/index.rst
Expand Up @@ -45,7 +45,6 @@ access any SymPy module, or use this contens:
solvers/solvers.rst
solvers/diophantine.rst
solvers/inequalities.rst
solvers/solveset.rst
tensor/index.rst
utilities/index.rst
parsing.rst
Expand Down
55 changes: 0 additions & 55 deletions doc/modules/solvers/solveset.rst

This file was deleted.

14 changes: 7 additions & 7 deletions sympy/assumptions/assume.py
Expand Up @@ -20,16 +20,16 @@ class to create your own local assumptions contexts. It is basically a thin
========
>>> from sympy import AppliedPredicate, Q
>>> from sympy.assumptions.assume import global_assumptions
>>> global_assumptions
AssumptionsContext()
>>> from sympy.assumptions.assume import global_assumptions, AssumptionsContext
>>> global_assumptions == AssumptionsContext([])
True
>>> from sympy.abc import x
>>> global_assumptions.add(Q.real(x))
>>> global_assumptions
AssumptionsContext([Q.real(x)])
>>> global_assumptions == AssumptionsContext([Q.real(x)])
True
>>> global_assumptions.remove(Q.real(x))
>>> global_assumptions
AssumptionsContext()
>>> global_assumptions == AssumptionsContext([])
True
>>> global_assumptions.clear()
"""
Expand Down
2 changes: 1 addition & 1 deletion sympy/categories/baseclasses.py
Expand Up @@ -570,7 +570,7 @@ class Diagram(Basic):
{g*f:A-->C: EmptySet(), id:A-->A: EmptySet(), id:B-->B: EmptySet(), id:C-->C:
EmptySet(), f:A-->B: EmptySet(), g:B-->C: EmptySet()}
>>> d = Diagram([f, g], {g * f: "unique"})
>>> pprint(d.conclusions)
>>> pprint(d.conclusions, use_unicode=False)
{g*f:A-->C: {unique}}
References
Expand Down
10 changes: 6 additions & 4 deletions sympy/categories/diagram_drawing.py
Expand Up @@ -1313,17 +1313,19 @@ def morphisms(self):
>>> from sympy.categories import Object, NamedMorphism
>>> from sympy.categories import Diagram, DiagramGrid
>>> from sympy.sets import EmptySet
>>> A = Object("A")
>>> B = Object("B")
>>> C = Object("C")
>>> f = NamedMorphism(A, B, "f")
>>> g = NamedMorphism(B, C, "g")
>>> diagram = Diagram([f, g])
>>> grid = DiagramGrid(diagram)
>>> grid.morphisms
{NamedMorphism(Object("A"), Object("B"), "f"): EmptySet(),
NamedMorphism(Object("B"), Object("C"), "g"): EmptySet()}
>>> grid.morphisms == {NamedMorphism(Object("A"),
... Object("B"), "f"): EmptySet(),
... NamedMorphism(Object("B"),
... Object("C"), "g"): EmptySet()}
True
"""
return self._morphisms

Expand Down
24 changes: 12 additions & 12 deletions sympy/combinatorics/perm_groups.py
Expand Up @@ -2057,10 +2057,10 @@ def orbit(self, alpha, action='tuples'):
>>> from sympy.combinatorics.perm_groups import PermutationGroup
>>> a = Permutation([1, 2, 0, 4, 5, 6, 3])
>>> G = PermutationGroup([a])
>>> G.orbit(0)
set([0, 1, 2])
>>> G.orbit([0, 4], 'union')
set([0, 1, 2, 3, 4, 5, 6])
>>> G.orbit(0) == {0, 1, 2}
True
>>> G.orbit([0, 4], 'union') == {0, 1, 2, 3, 4, 5, 6}
True
See Also
========
Expand Down Expand Up @@ -2156,8 +2156,8 @@ def orbits(self, rep=False):
>>> a = Permutation(1, 5)(2, 3)(4, 0, 6)
>>> b = Permutation(1, 5)(3, 4)(2, 6, 0)
>>> G = PermutationGroup([a, b])
>>> G.orbits()
[set([0, 2, 3, 4, 6]), set([1, 5])]
>>> G.orbits() ==[{0, 2, 3, 4, 6}, {1, 5}]
True
"""
return _orbits(self._degree, self._generators)

Expand Down Expand Up @@ -3233,10 +3233,10 @@ def _orbit(degree, generators, alpha, action='tuples'):
>>> from sympy.combinatorics.perm_groups import PermutationGroup, _orbit
>>> a = Permutation([1, 2, 0, 4, 5, 6, 3])
>>> G = PermutationGroup([a])
>>> _orbit(G.degree, G.generators, 0)
set([0, 1, 2])
>>> _orbit(G.degree, G.generators, [0, 4], 'union')
set([0, 1, 2, 3, 4, 5, 6])
>>> _orbit(G.degree, G.generators, 0) == {0, 1, 2}
True
>>> _orbit(G.degree, G.generators, [0, 4], 'union') == {0, 1, 2, 3, 4, 5, 6}
True
See Also
========
Expand Down Expand Up @@ -3296,8 +3296,8 @@ def _orbits(degree, generators):
>>> from sympy.combinatorics.perm_groups import PermutationGroup, _orbits
>>> a = Permutation([0, 2, 1])
>>> b = Permutation([1, 0, 2])
>>> _orbits(a.size, [a, b])
[set([0, 1, 2])]
>>> _orbits(a.size, [a, b]) == [{0, 1, 2}]
True
"""

seen = set() # elements that have already appeared in orbits
Expand Down
8 changes: 4 additions & 4 deletions sympy/combinatorics/permutations.py
Expand Up @@ -1533,10 +1533,10 @@ def atoms(self):
========
>>> from sympy.combinatorics import Permutation
>>> Permutation([0, 1, 2, 3, 4, 5]).atoms()
set([0, 1, 2, 3, 4, 5])
>>> Permutation([[0, 1], [2, 3], [4, 5]]).atoms()
set([0, 1, 2, 3, 4, 5])
>>> Permutation([0, 1, 2, 3, 4, 5]).atoms() == {0, 1, 2, 3, 4, 5}
True
>>> Permutation([[0, 1], [2, 3], [4, 5]]).atoms() == {0, 1, 2, 3, 4, 5}
True
"""
return set(self.array_form)

Expand Down
2 changes: 1 addition & 1 deletion sympy/combinatorics/tensor_can.py
Expand Up @@ -49,7 +49,7 @@ def dummy_sgs(dummies, sym, n):
========
>>> from sympy.combinatorics.tensor_can import dummy_sgs
>>> dummy_sgs(range(2, 8), 0, 8)
>>> dummy_sgs(list(range(2, 8)), 0, 8)
[[0, 1, 3, 2, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 5, 4, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 7, 6, 8, 9], [0, 1, 4, 5, 2, 3, 6, 7, 8, 9],
[0, 1, 2, 3, 6, 7, 4, 5, 8, 9]]
Expand Down
4 changes: 2 additions & 2 deletions sympy/concrete/expr_with_limits.py
Expand Up @@ -175,8 +175,8 @@ def free_symbols(self):
>>> from sympy import Sum
>>> from sympy.abc import x, y
>>> Sum(x, (x, y, 1)).free_symbols
set([y])
>>> Sum(x, (x, y, 1)).free_symbols == {y}
True
"""
# don't test for any special values -- nominal free symbols
# should be returned, e.g. don't return set() if the
Expand Down
12 changes: 7 additions & 5 deletions sympy/core/add.py
Expand Up @@ -277,13 +277,15 @@ def as_coefficients_dict(a):
Examples
========
>>> from collections import defaultdict
>>> from sympy.abc import a, x
>>> (3*x + a*x + 4).as_coefficients_dict()
{1: 4, x: 3, a*x: 1}
>>> _[a]
>>> d = (3*x + a*x + 4).as_coefficients_dict()
>>> d == defaultdict(int, {1: 4, x: 3, a*x: 1})
True
>>> d[a]
0
>>> (3*a*x).as_coefficients_dict()
{a*x: 3}
>>> (3*a*x).as_coefficients_dict() == defaultdict(int, {a*x: 3})
True
"""

d = defaultdict(list)
Expand Down
83 changes: 41 additions & 42 deletions sympy/core/basic.py
Expand Up @@ -119,7 +119,7 @@ def _hashable_content(self):

@property
def assumptions0(self):
"""
r"""
Return object `type` assumptions.
For example:
Expand All @@ -138,11 +138,12 @@ def assumptions0(self):
>>> x.assumptions0
{'commutative': True}
>>> x = Symbol("x", positive=True)
>>> x.assumptions0
{'commutative': True, 'complex': True, 'extended_real': True,
'hermitian': True, 'imaginary': False, 'negative': False,
'nonnegative': True, 'nonpositive': False, 'nonzero': True,
'positive': True, 'zero': False}
>>> x.assumptions0 == \
... {'commutative': True, 'complex': True, 'extended_real': True,
... 'hermitian': True, 'imaginary': False, 'negative': False,
... 'nonnegative': True, 'nonpositive': False, 'nonzero': True,
... 'positive': True, 'zero': False}
True
"""
return {}

Expand Down Expand Up @@ -406,8 +407,8 @@ def atoms(self, *types):
>>> from sympy import I, pi, sin
>>> from sympy.abc import x, y
>>> (1 + x + 2*sin(y + I*pi)).atoms()
set([1, 2, I, pi, x, y])
>>> (1 + x + 2*sin(y + I*pi)).atoms() == {1, 2, I, pi, x, y}
True
If one or more types are given, the results will contain only
those types of atoms.
Expand All @@ -416,37 +417,37 @@ def atoms(self, *types):
========
>>> from sympy import Number, NumberSymbol, Symbol
>>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol)
set([x, y])
>>> (1 + x + 2*sin(y + I*pi)).atoms(Symbol) == {x, y}
True
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number)
set([1, 2])
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number) == {1, 2}
True
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol)
set([1, 2, pi])
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol) == {1, 2, pi}
True
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I)
set([1, 2, I, pi])
>>> (1 + x + 2*sin(y + I*pi)).atoms(Number, NumberSymbol, I) == {1, 2, I, pi}
True
Note that I (imaginary unit) and zoo (complex infinity) are special
types of number symbols and are not part of the NumberSymbol class.
The type can be given implicitly, too:
>>> (1 + x + 2*sin(y + I*pi)).atoms(x) # x is a Symbol
set([x, y])
>>> (1 + x + 2*sin(y + I*pi)).atoms(x) == {x, y}
True
Be careful to check your assumptions when using the implicit option
since ``S(1).is_Integer = True`` but ``type(S(1))`` is ``One``, a special type
of sympy atom, while ``type(S(2))`` is type ``Integer`` and will find all
integers in an expression:
>>> from sympy import S
>>> (1 + x + 2*sin(y + I*pi)).atoms(S(1))
set([1])
>>> (1 + x + 2*sin(y + I*pi)).atoms(S(1)) == {1}
True
>>> (1 + x + 2*sin(y + I*pi)).atoms(S(2))
set([1, 2])
>>> (1 + x + 2*sin(y + I*pi)).atoms(S(2)) == {1, 2}
True
Finally, arguments to atoms() can select more than atomic atoms: any
sympy type (loaded in core/__init__.py) can be listed as an argument
Expand All @@ -456,14 +457,13 @@ def atoms(self, *types):
>>> from sympy import Function, Mul
>>> from sympy.core.function import AppliedUndef
>>> f = Function('f')
>>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function)
set([f(x), sin(y + I*pi)])
>>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef)
set([f(x)])
>>> (1 + x + 2*sin(y + I*pi)).atoms(Mul)
set([I*pi, 2*sin(y + I*pi)])
>>> (1 + f(x) + 2*sin(y + I*pi)).atoms(Function) == {f(x), sin(y + I*pi)}
True
>>> (1 + f(x) + 2*sin(y + I*pi)).atoms(AppliedUndef) == {f(x)}
True
>>> (1 + x + 2*sin(y + I*pi)).atoms(Mul) == {I*pi, 2*sin(y + I*pi)}
True
"""
if types:
types = tuple(
Expand Down Expand Up @@ -1443,13 +1443,13 @@ def match(self, pattern, old=False):
>>> q = Wild("q")
>>> r = Wild("r")
>>> e = (x+y)**(x+y)
>>> e.match(p**p)
{p_: x + y}
>>> e.match(p**q)
{p_: x + y, q_: x + y}
>>> e.match(p**p) == {p: x + y}
True
>>> e.match(p**q) == {p: x + y, q: x + y}
True
>>> e = (2*x)**2
>>> e.match(p*q**r)
{p_: 4, q_: x, r_: 2}
>>> e.match(p*q**r) == {p: 4, q: x, r: 2}
True
>>> (p*q**r).xreplace(e.match(p*q**r))
4*x**2
Expand Down Expand Up @@ -1682,13 +1682,12 @@ def _atomic(e):
>>> from sympy.abc import x, y
>>> from sympy.core.basic import _atomic
>>> f = Function('f')
>>> _atomic(x + y)
set([x, y])
>>> _atomic(x + f(y))
set([x, f(y)])
>>> _atomic(Derivative(f(x), x) + cos(x) + y)
set([y, cos(x), Derivative(f(x), x)])
>>> _atomic(x + y) == {x, y}
True
>>> _atomic(x + f(y)) == {x, f(y)}
True
>>> _atomic(Derivative(f(x), x) + cos(x) + y) == {y, cos(x), Derivative(f(x), x)}
True
"""
from sympy import Derivative, Function, Symbol
pot = preorder_traversal(e)
Expand Down
8 changes: 4 additions & 4 deletions sympy/core/compatibility.py
Expand Up @@ -166,10 +166,10 @@ class MyClass(object, metaclass=Meta):
are the base classes. Note that if the base class is just ``object``, you
may omit it.
>>> MyClass.__mro__
(<class 'MyClass'>, <... 'object'>)
>>> type(MyClass)
<class 'Meta'>
>>> MyClass.__mro__ == (MyClass, object)
True
>>> type(MyClass) is Meta
True
"""
# This requires a bit of explanation: the basic idea is to make a dummy
Expand Down

0 comments on commit 023b144

Please sign in to comment.