Skip to content

Commit

Permalink
Merge 2c29fc1 into 1de5ffe
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Apr 13, 2015
2 parents 1de5ffe + 2c29fc1 commit e969cb5
Show file tree
Hide file tree
Showing 102 changed files with 602 additions and 372 deletions.
4 changes: 2 additions & 2 deletions bin/coverage_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _get_arg_list(name, fobj):
arg_list.append(argspec.keywords)

# Truncate long arguments
arg_list = map(lambda x: x[:trunc], arg_list)
arg_list = [x[:trunc] for x in arg_list]

# Construct the parameter string (enclosed in brackets)
str_param = "%s(%s)" % (name, ', '.join(arg_list))
Expand Down Expand Up @@ -396,7 +396,7 @@ def coverage(module_path, verbose=False, no_color=False, sphinx=True):
contained. It then goes through each of the classes/functions to get
the docstring and doctest coverage of the module. """

# Import the package and find membmers
# Import the package and find members
m = None
try:
__import__(module_path)
Expand Down
6 changes: 4 additions & 2 deletions examples/advanced/gibbs_phenomenon.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def l2_norm(f, lim):
x ...... the independent variable in f over which to integrate
a, b ... the limits of the interval
Example:
Examples
========
>>> from sympy import Symbol
>>> from gibbs_phenomenon import l2_norm
Expand Down Expand Up @@ -61,7 +62,8 @@ def l2_gram_schmidt(list, lim):
"""
Orthonormalizes the "list" of functions using the Gram-Schmidt process.
Example:
Examples
========
>>> from sympy import Symbol
>>> from gibbs_phenomenon import l2_gram_schmidt
Expand Down
4 changes: 2 additions & 2 deletions examples/intermediate/vandermonde.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def comb_w_rep(n, k):


def vandermonde(order, dim=1, syms='a b c d'):
"""Comptutes a Vandermonde matrix of given order and dimension.
"""Computes a Vandermonde matrix of given order and dimension.
Define syms to give beginning strings for temporary variables.
Expand Down Expand Up @@ -118,7 +118,7 @@ def main():
pprint(V)

print('-'*79)
print("Computing the determinate and comparing to \sum_{0<i<j<=3}(a_j - a_i)")
print("Computing the determinant and comparing to \sum_{0<i<j<=3}(a_j - a_i)")

det_sum = 1
for j in range(order + 1):
Expand Down
6 changes: 4 additions & 2 deletions sympy/assumptions/handlers/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class AskFiniteHandler(CommonHandler):
Test that an expression is finite respect to all its variables.
Examples of usage:
Examples
========
>>> from sympy import Symbol, Q
>>> from sympy.assumptions.handlers.calculus import AskFiniteHandler
Expand All @@ -79,7 +80,8 @@ def Symbol(expr, assumptions):
"""
Handles Symbol.
Examples:
Examples
========
>>> from sympy import Symbol, Q
>>> from sympy.assumptions.handlers.calculus import AskFiniteHandler
Expand Down
3 changes: 2 additions & 1 deletion sympy/assumptions/handlers/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class AskNegativeHandler(CommonHandler):
Test that an expression is less (strict) than zero.
Examples:
Examples
========
>>> from sympy import ask, Q, pi
>>> ask(Q.negative(pi+1)) # this calls AskNegativeHandler.Add
Expand Down
2 changes: 1 addition & 1 deletion sympy/calculus/euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def euler_equations(L, funcs=(), vars=()):
\frac{\partial g(x,y)}{\partial y},x,y\right)
In many cases it is not necessary to provide anything, except the
Lagrangian, it will be autodetected (and an error raised if this
Lagrangian, it will be auto-detected (and an error raised if this
couldn't be done).
funcs : Function or an iterable of Functions
Expand Down
8 changes: 4 additions & 4 deletions sympy/combinatorics/graycode.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ def get_subset_from_bitstring(super_set, bitstring):
========
>>> from sympy.combinatorics.graycode import get_subset_from_bitstring
>>> get_subset_from_bitstring(['a','b','c','d'], '0011')
>>> get_subset_from_bitstring(['a', 'b', 'c', 'd'], '0011')
['c', 'd']
>>> get_subset_from_bitstring(['c','a','c','c'], '1100')
>>> get_subset_from_bitstring(['c', 'a', 'c', 'c'], '1100')
['c', 'a']
See Also
Expand All @@ -398,10 +398,10 @@ def graycode_subsets(gray_code_set):
========
>>> from sympy.combinatorics.graycode import graycode_subsets
>>> list(graycode_subsets(['a','b','c']))
>>> list(graycode_subsets(['a', 'b', 'c']))
[[], ['c'], ['b', 'c'], ['b'], ['a', 'b'], ['a', 'b', 'c'], \
['a', 'c'], ['a']]
>>> list(graycode_subsets(['a','b','c','c']))
>>> list(graycode_subsets(['a', 'b', 'c', 'c']))
[[], ['c'], ['c', 'c'], ['c'], ['b', 'c'], ['b', 'c', 'c'], \
['b', 'c'], ['b'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'c'], \
['a', 'b', 'c'], ['a', 'c'], ['a', 'c', 'c'], ['a', 'c'], ['a']]
Expand Down
4 changes: 2 additions & 2 deletions sympy/combinatorics/group_constructs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def DirectProduct(*groups):
>>> from sympy.combinatorics.group_constructs import DirectProduct
>>> from sympy.combinatorics.named_groups import CyclicGroup
>>> C = CyclicGroup(4)
>>> G = DirectProduct(C,C,C)
>>> G = DirectProduct(C, C, C)
>>> G.order()
64
Expand Down Expand Up @@ -55,7 +55,7 @@ def DirectProduct(*groups):
for j in range(current_gen, current_gen + gens_count[i]):
gen = ((groups[i].generators)[j - current_gen]).array_form
array_gens[j][current_deg:current_deg + degrees[i]] = \
[ x + current_deg for x in gen]
[x + current_deg for x in gen]
current_gen += gens_count[i]
current_deg += degrees[i]
perm_gens = list(uniq([_af_new(list(a)) for a in array_gens]))
Expand Down
3 changes: 2 additions & 1 deletion sympy/combinatorics/named_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def SymmetricGroup(n):


def RubikGroup(n):
"""Return a group of Rubik's cube generators.
"""Return a group of Rubik's cube generators
>>> from sympy.combinatorics.named_groups import RubikGroup
>>> RubikGroup(2).is_group()
False
Expand Down
3 changes: 2 additions & 1 deletion sympy/combinatorics/partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __new__(cls, *partition):
if has_dups(partition):
raise ValueError("Partition contained duplicated elements.")

obj = FiniteSet.__new__(cls, *list(map(lambda x: FiniteSet(*x), args)))
obj = FiniteSet.__new__(cls, *[FiniteSet(*x) for x in args])
obj.members = tuple(partition)
obj.size = len(partition)
return obj
Expand Down Expand Up @@ -323,6 +323,7 @@ def __new__(cls, partition, integer=None):
If the value that the partion should sum to is given first, a check
will be made to see n error will be raised if there is a discrepancy:
>>> IntegerPartition(10, [5, 4, 3, 1])
Traceback (most recent call last):
...
Expand Down
18 changes: 9 additions & 9 deletions sympy/combinatorics/perm_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,11 +2055,11 @@ def orbit(self, alpha, action='tuples'):
>>> from sympy.combinatorics import Permutation
>>> from sympy.combinatorics.perm_groups import PermutationGroup
>>> a = Permutation([1,2,0,4,5,6,3])
>>> a = Permutation([1, 2, 0, 4, 5, 6, 3])
>>> G = PermutationGroup([a])
>>> G.orbit(0)
set([0, 1, 2])
>>> G.orbit([0,4], 'union')
>>> G.orbit([0, 4], 'union')
set([0, 1, 2, 3, 4, 5, 6])
See Also
Expand Down Expand Up @@ -2153,8 +2153,8 @@ def orbits(self, rep=False):
>>> from sympy.combinatorics.permutations import Permutation
>>> from sympy.combinatorics.perm_groups import PermutationGroup
>>> a = Permutation(1,5)(2,3)(4,0,6)
>>> b = Permutation(1,5)(3,4)(2,6,0)
>>> 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])]
Expand Down Expand Up @@ -2725,9 +2725,9 @@ def schreier_vector(self, alpha):
>>> from sympy.combinatorics.perm_groups import PermutationGroup
>>> from sympy.combinatorics.permutations import Permutation
>>> a = Permutation([2,4,6,3,1,5,0])
>>> b = Permutation([0,1,3,5,4,6,2])
>>> G = PermutationGroup([a,b])
>>> a = Permutation([2, 4, 6, 3, 1, 5, 0])
>>> b = Permutation([0, 1, 3, 5, 4, 6, 2])
>>> G = PermutationGroup([a, b])
>>> G.schreier_vector(0)
[-1, None, 0, 1, None, 1, 0]
Expand Down Expand Up @@ -3085,7 +3085,7 @@ def transitivity_degree(self):
>>> from sympy.combinatorics.permutations import Permutation
>>> a = Permutation([1, 2, 0])
>>> b = Permutation([1, 0, 2])
>>> G = PermutationGroup([a,b])
>>> G = PermutationGroup([a, b])
>>> G.transitivity_degree
3
Expand Down Expand Up @@ -3223,7 +3223,7 @@ def _orbit(degree, generators, alpha, action='tuples'):
'union' - computes the union of the orbits of the points in the list
'tuples' - computes the orbit of the list interpreted as an ordered
tuple under the group action ( i.e., g((1,2,3)) = (g(1), g(2), g(3)) )
tuple under the group action ( i.e., g((1, 2, 3)) = (g(1), g(2), g(3)) )
'sets' - computes the orbit of the list interpreted as a sets
Examples
Expand Down
3 changes: 2 additions & 1 deletion sympy/combinatorics/subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ def subset_indices(self, subset, superset):
"""Return indices of subset in superset in a list; the list is empty
if all elements of subset are not in superset.
Examples::
Examples
========
>>> from sympy.combinatorics import Subset
>>> superset = [1, 3, 2, 5, 4]
Expand Down
2 changes: 2 additions & 0 deletions sympy/combinatorics/tensor_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,13 @@ def tensor_gens(base, gens, list_free_indices, sym=0):
>>> Permutation.print_cyclic = True
two symmetric tensors with 3 indices without free indices
>>> base, gens = get_symmetric_group_sgs(3)
>>> tensor_gens(base, gens, [[], []])
(8, [0, 1, 3, 4], [Permutation(7)(0, 1), Permutation(7)(1, 2), Permutation(7)(3, 4), Permutation(7)(4, 5), Permutation(7)(0, 3)(1, 4)(2, 5)])
two symmetric tensors with 3 indices with free indices in slot 1 and 0
>>> tensor_gens(base, gens, [[1],[0]])
(8, [0, 4], [Permutation(7)(0, 2), Permutation(7)(4, 5)])
Expand Down
6 changes: 5 additions & 1 deletion sympy/core/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,14 +1551,17 @@ def rewrite(self, *args, **hints):
>>> from sympy.abc import x
Unspecified pattern:
>>> sin(x).rewrite(exp)
-I*(exp(I*x) - exp(-I*x))/2
Pattern as a single function:
>>> sin(x).rewrite(sin, exp)
-I*(exp(I*x) - exp(-I*x))/2
Pattern as a list of functions:
>>> sin(x).rewrite([sin, ], exp)
-I*(exp(I*x) - exp(-I*x))/2
Expand Down Expand Up @@ -1788,7 +1791,8 @@ def skip(self):
Skip yielding current node's (last yielded node's) subtrees.
Examples
--------
========
>>> from sympy.core import symbols
>>> from sympy.core.basic import preorder_traversal
>>> x, y, z = symbols('x y z')
Expand Down
12 changes: 11 additions & 1 deletion sympy/core/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def default_sort_key(item, order=None):
Examples
========
>>> from sympy import S, I, default_sort_key
>>> from sympy import S, I, default_sort_key, sin, cos, sqrt
>>> from sympy.core.function import UndefinedFunction
>>> from sympy.abc import x
Expand Down Expand Up @@ -419,9 +419,19 @@ def default_sort_key(item, order=None):
The order of terms obtained when using these keys is the order that would
be obtained if those terms were *factors* in a product.
Although it is useful for quickly putting expressions in canonical order,
it does not sort expressions based on their complexity defined by the
number of operations, power of variables and others:
>>> sorted([sin(x)*cos(x), sin(x)], key=default_sort_key)
[sin(x)*cos(x), sin(x)]
>>> sorted([x, x**2, sqrt(x), x**3], key=default_sort_key)
[sqrt(x), x, x**2, x**3]
See Also
========
ordered
sympy.core.expr.Expr.as_ordered_factors
sympy.core.expr.Expr.as_ordered_terms
"""
Expand Down
3 changes: 3 additions & 0 deletions sympy/core/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,9 @@ def is_rational_function(self, *syms):
See also is_algebraic_expr().
"""
if self in [S.NaN, S.Infinity, -S.Infinity, S.ComplexInfinity]:
return False

if syms:
syms = set(map(sympify, syms))
else:
Expand Down
4 changes: 3 additions & 1 deletion sympy/core/exprtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,9 @@ def factor_nc(expr):
"""Return the factored form of ``expr`` while handling non-commutative
expressions.
**examples**
Examples
========
>>> from sympy.core.exprtools import factor_nc
>>> from sympy import Symbol
>>> from sympy.abc import x
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def apply_beta_to_alpha_route(alpha_implications, beta_rules):
ximpls.add(bimpl)

# we introduced new implication - now we have to restore
# completness of the whole set.
# completeness of the whole set.
bimpl_impl = x_impl.get(bimpl)
if bimpl_impl is not None:
ximpls |= bimpl_impl[0]
Expand Down
8 changes: 4 additions & 4 deletions sympy/core/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def _sort_variables(cls, vars):
* Derivatives wrt symbols and non-symbols don't commute.
Examples
--------
========
>>> from sympy import Derivative, Function, symbols
>>> vsort = Derivative._sort_variables
Expand Down Expand Up @@ -1301,7 +1301,7 @@ def _eval_subs(self, old, new):
if match:
variables = self_vars_front + self_vars
return Derivative(new, *variables)
return Derivative(*map(lambda x: x._subs(old, new), self.args))
return Derivative(*(x._subs(old, new) for x in self.args))

def _eval_lseries(self, x, logx):
dx = self.args[1:]
Expand Down Expand Up @@ -1937,8 +1937,8 @@ def _eval_expand_hint(self, **hints):
kind of 'expansion'. For hints that simply rewrite an expression, use the
.rewrite() API.
Example
-------
Examples
========
>>> from sympy import Expr, sympify
>>> class MyClass(Expr):
Expand Down
6 changes: 5 additions & 1 deletion sympy/core/mul.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,10 @@ def _handle_for_oo(c_part, coeff_sign):

# 0
elif coeff is S.Zero:
# we know for sure the result will be 0
# we know for sure the result will be 0 except the multiplicand
# is infinity
if any(c.is_finite == False for c in c_part):
return [S.NaN], [], order_symbols
return [coeff], [], order_symbols

# check for straggling Numbers that were produced
Expand Down Expand Up @@ -1534,6 +1537,7 @@ def prod(a, start=1):
True
You can start the product at something other than 1:
>>> prod([1, 2], 3)
6
Expand Down
4 changes: 2 additions & 2 deletions sympy/core/sympify.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class CantSympify(object):
"""
Mix in this trait to a class to disallow sympification of its instances.
Example
=======
Examples
========
>>> from sympy.core.sympify import sympify, CantSympify
Expand Down
Loading

0 comments on commit e969cb5

Please sign in to comment.