Skip to content

Commit

Permalink
merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
smichr committed Nov 21, 2014
2 parents 5403e74 + 6e0ee05 commit c7e7af1
Show file tree
Hide file tree
Showing 99 changed files with 1,644 additions and 674 deletions.
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,6 @@ Peter Brady <[email protected]> peter <[email protected]>
Craig A. Stoudt <[email protected]> cstoudt <[email protected]>
Raj <[email protected]> raj454raj <[email protected]>
John V. Siratt <[email protected]> John Siratt <[email protected]>
Ted Dokos <[email protected]> ted-dokos <[email protected]>
Akshat Jain <[email protected]> akshat_jain <[email protected]>
Akshat Jain <[email protected]> jugnu <[email protected]>
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
- SPLIT="3/4"
- SPLIT="4/4"
global:
secure: uJycOcgT3Rg9TsU6ID2UMHc56Fh6Q70p1/mFiod8r97g8zER9kWTZ2GVDSRiw1Nfh0Wojcy04PAG3t5m9bwM08YF8qZy1PJkCb/pu7PN8Hzt+6FSBb84gGEXMiv1xuZWSQ0pUuBa1Lfcxuq6m2/eA8aNfgoqnpLgR8zeg/2xhFw=
secure: "SyoeHaDi9vRPJ5X0JFY5/nQif66u+fehtqUg7F8ILoNrwugJcs+u4VZm1sJ7Cv2h6uGoNRAfkkrahxxj2mKCgpqbY2MdDAZ+ru5wn5R0NjYjTpEz7ET4Xq5o+gca+mhFMkiutYihM73+AaIKCX0vfC9yb8WBPXzbbrv8vVvQr6Y="
python:
- 2.6
- 2.7
Expand Down Expand Up @@ -122,7 +122,8 @@ install:
fi
script:
- bin/test_travis.sh
# - if [[ "${TEST_SPHINX}" == "true" ]]; then
# bin/deploy_doc.sh;
# fi
notifications:
email: false
after_success:
- bin/build_doc.sh
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,6 @@ Hamish Dickson <[email protected]>
Michael Gallaspy <[email protected]>
Roman Inflianskas <[email protected]>
Duane Nykamp <[email protected]>
Ted Dokos <[email protected]>
Sunny Aggarwal <[email protected]>
Akshat Jain <[email protected]>
28 changes: 11 additions & 17 deletions bin/build_doc.sh → bin/deploy_doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#
# Following is the procedure to get the access token:
#
# $ curl -X POST -u <github_username> -H "Content-Type: application/json" -d\
# "{\"scopes\":[\"public_repo\"],\"note\":\"token for pushing from travis\"}"\
# https://api.github.com/authorizations
# $ curl -X POST -u <github_username> -H "Content-Type: application/json" -H "X-GitHub-OTP: 2FA_TOKEN" -d "{\"scopes\":[\"public_repo\"],\"note\":\"token for pushing from Travis for SymPy\"}" https://api.github.com/authorizations
#
# Replace 2FA_TOKEN with your two-factor token generated by SMS or the
# application.
#
# It'll give you a JSON response having a key called "token".
#
Expand All @@ -24,20 +25,9 @@
# Exit on error
set -e

ACTUAL_TRAVIS_JOB_NUMBER=`echo $TRAVIS_JOB_NUMBER| cut -d'.' -f 2`

if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$ACTUAL_TRAVIS_JOB_NUMBER" == "1" ]; then

echo "Installing dependencies"
sudo apt-get install --no-install-recommends graphviz inkscape texlive texlive-xetex texlive-fonts-recommended texlive-latex-extra lmodern librsvg2-bin imagemagick docbook2x
pip install "sphinx==1.1.3"

echo -e "Building docs"
cd doc
make clean
make html
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then

cd ../../
cd ../
echo -e "Setting git attributes"
git config --global user.email "[email protected]"
git config --global user.name "SymPy (Travis CI)"
Expand All @@ -48,12 +38,16 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$ACTUAL_TRAVIS_JOB_NUMBER" == "1"
cd gh-pages
git remote rm origin
git remote add origin https://${GH_TOKEN}@github.com/sympy/sympy_doc.git > /dev/null 2>&1
git fetch origin > /dev/null 2>&1
git branch --set-upstream-to=origin/gh-pages gh-pages
rm -rf dev/
cp -R ../sympy/doc/_build/html dev/
git add -A dev/
./generate_indexes.py

git commit -am "Update dev doc after building $TRAVIS_BUILD_NUMBER"
echo -e "Pulling"
git pull > /dev/null 2>&1
echo -e "Pushing commit"
git push -fq origin gh-pages > /dev/null 2>&1
git push -q origin gh-pages > /dev/null 2>&1
fi
3 changes: 2 additions & 1 deletion bin/mailmap_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# - Check doc/src/aboutus.rst
# - Make it easier to update .mailmap or AUTHORS with the correct entries.

from __future__ import unicode_literals
from __future__ import print_function

import os
Expand Down Expand Up @@ -46,7 +47,7 @@
os.path.pardir, "AUTHORS"))) as fd:
AUTHORS = unicode(fd.read(), 'utf-8')

firstauthor = u"Ondřej Čertík"
firstauthor = "Ondřej Čertík"

authors = AUTHORS[AUTHORS.find(firstauthor):].strip().split('\n')

Expand Down
8 changes: 4 additions & 4 deletions bin/test_isolated
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ def main():
parser.error("too many arguments")
if options.nosetests:
if options.verbose:
print "Generating nosetests isolated testsuite..."
print("Generating nosetests isolated testsuite...")
generate_test_script2("nosetests")
else:
if options.verbose:
print "Generating py.test isolated testsuite..."
print("Generating py.test isolated testsuite...")
generate_test_script1("py.test")
if options.verbose:
print "Done. Run (search for 'COMMIT' in the less environment):"
print "/tmp/test_sympy.sh | less"
print("Done. Run (search for 'COMMIT' in the less environment):")
print("/tmp/test_sympy.sh | less")

if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion bin/test_travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ set -x
if [[ "${TEST_SPHINX}" == "true" ]]; then
cd doc
make html-errors
make clean
make man
make latex
cd _build/latex
Expand Down
3 changes: 3 additions & 0 deletions doc/src/aboutus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ want to be mentioned here, so see our repository history for a full list).
#. Michael Gallaspy: improve handling of inequalities involving RootOf
#. Roman Inflianskas: add svg support to preview
#. Duane Nykamp: improved function handling in parse_expr
#. Ted Dokos: implemented interleaving for unions
#. Sunny Aggarwal: fix Integral.transform method
#. Akshat Jain: nsimplify returns ints quickly

Up-to-date list in the order of the first contribution is given in the `AUTHORS
<https://github.com/sympy/sympy/blob/master/AUTHORS>`_ file.
Expand Down
12 changes: 7 additions & 5 deletions sympy/categories/baseclasses.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function, division

from sympy.core import Basic, Dict, Symbol, Tuple
from sympy.core import S, Basic, Dict, Symbol, Tuple
from sympy.core.compatibility import xrange, iterable
from sympy.sets import Set, FiniteSet, EmptySet

Expand Down Expand Up @@ -722,8 +722,8 @@ def __new__(cls, *args):

for morphism in conclusions_arg:
# Check that no new objects appear in conclusions.
if (morphism.domain in objects) and \
(morphism.codomain in objects):
if ((objects.contains(morphism.domain) == S.true) and
(objects.contains(morphism.codomain) == S.true)):
# No need to add identities and recurse
# composites this time.
Diagram._add_morphism_closure(
Expand Down Expand Up @@ -920,12 +920,14 @@ def subdiagram_from_objects(self, objects):

new_premises = {}
for morphism, props in self.premises.items():
if (morphism.domain in objects) and (morphism.codomain in objects):
if ((objects.contains(morphism.domain) == S.true) and
(objects.contains(morphism.codomain) == S.true)):
new_premises[morphism] = props

new_conclusions = {}
for morphism, props in self.conclusions.items():
if (morphism.domain in objects) and (morphism.codomain in objects):
if ((objects.contains(morphism.domain) == S.true) and
(objects.contains(morphism.codomain) == S.true)):
new_conclusions[morphism] = props

return Diagram(new_premises, new_conclusions)
5 changes: 3 additions & 2 deletions sympy/combinatorics/tests/test_prufer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def test_prufer():

# accept iterables but convert to list of lists
tree = [(0, 1), (1, 5), (0, 3), (0, 2), (2, 6), (4, 7), (2, 4)]
Prufer(tree).tree_repr == tree
Prufer(set(tree)).tree_repr == tree
tree_lists = [list(t) for t in tree]
assert Prufer(tree).tree_repr == tree_lists
assert sorted(Prufer(set(tree)).tree_repr) == sorted(tree_lists)

raises(ValueError, lambda: Prufer([[1, 2], [3, 4]])) # 0 is missing
assert Prufer(*Prufer.edges([1, 2], [3, 4])).prufer_repr == [1, 3]
Expand Down
6 changes: 4 additions & 2 deletions sympy/concrete/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Product(ExprWithIntLimits):
Direct computation currently fails:
>>> W.doit()
nan
Product(4*i**2/((2*i - 1)*(2*i + 1)), (i, 1, oo))
But we can approach the infinite product by a limit of finite products:
Expand Down Expand Up @@ -219,7 +219,7 @@ def doit(self, **hints):
f = 1 / f

g = self._eval_product(f, (i, a, b))
if g is None:
if g in (None, S.NaN):
return self.func(powsimp(f), *self.limits[index:])
else:
f = g
Expand All @@ -245,6 +245,8 @@ def _eval_product(self, term, limits):
(k, a, n) = limits

if k not in term.free_symbols:
if (term - 1).is_zero:
return S.One
return term**(n - a + 1)

if a == n:
Expand Down
4 changes: 4 additions & 0 deletions sympy/concrete/tests/test_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ def test_simple_products():
raises(ValueError, lambda: Product(n, k, 1, 10))
raises(ValueError, lambda: Product(n, (k, 1)))

assert product(1, (n, 1, oo)) == 1 # issue 8301
assert product(2, (n, 1, oo)) == oo
assert product(-1, (n, 1, oo)).func is Product


def test_multiple_products():
assert product(x, (n, 1, k), (k, 1, m)) == x**(m**2/2 + m/2)
Expand Down
12 changes: 9 additions & 3 deletions sympy/concrete/tests/test_sums_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def test_limit_subs():
F(a, (a, c, 4))
assert F(x, (x, 1, x + y)).subs(x, 1) == F(x, (x, 1, y + 1))


def test_function_subs():
f = Function("f")
S = Sum(x*f(y),(x,0,oo),(y,0,oo))
Expand All @@ -486,6 +487,7 @@ def test_function_subs():
S = Sum(x*f(y),(x,0,oo),(y,0,oo))
assert S.subs(f(y),y) == Sum(x*y,(x,0,oo),(y,0,oo))


def test_equality():
# if this fails remove special handling below
raises(ValueError, lambda: Sum(x, x))
Expand Down Expand Up @@ -698,6 +700,7 @@ def test_simplify():
assert simplify(Sum(x, (x, a, b))*Sum(x**2, (x, a, b))) == \
Sum(x, (x, a, b)) * Sum(x**2, (x, a, b))


def test_change_index():
b, v = symbols('b, v', integer = True)

Expand Down Expand Up @@ -757,9 +760,11 @@ def test_reverse_order():
assert Sum(x*y, (x, a, b), (y, 2, 5)).reverse_order(y, x) == \
Sum(x*y, (x, b + 1, a - 1), (y, 6, 1))


def test_issue_7097():
assert sum(x**n/n for n in range(1, 401)) == summation(x**n/n, (n, 1, 400))


def test_factor_expand_subs():
# test factoring
assert Sum(4 * x, (x, 1, y)).factor() == 4 * Sum(x, (x, 1, y))
Expand Down Expand Up @@ -801,9 +806,10 @@ def test_issue_2787():
binomial_dist = binomial(n, k)*p**k*(1 - p)**(n - k)
s = Sum(binomial_dist*k, (k, 0, n))
res = s.doit().simplify()
assert res == Piecewise((n*p, And(Or(-n + 1 < 0, -n + 1 >= 0),
Or(-n + 1 < 0, Ne(p/(p - 1), 1)), p*Abs(1/(p - 1)) <= 1)),
(Sum(k*p**k*(-p + 1)**(-k)*(-p + 1)**n*binomial(n, k), (k, 0, n)), True))
assert res == Piecewise(
(n*p, And(Or(-n + 1 < 0, Ne(p/(p - 1), 1)), p/Abs(p - 1) <= 1)),
(Sum(k*p**k*(-p + 1)**(-k)*(-p + 1)**n*binomial(n, k), (k, 0, n)),
True))


def test_issue_4668():
Expand Down
22 changes: 11 additions & 11 deletions sympy/core/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,30 +687,30 @@ def _eval_as_leading_term(self, x):

old = self

self = expand_mul(self)
if not self.is_Add:
return self.as_leading_term(x)
expr = expand_mul(self)
if not expr.is_Add:
return expr.as_leading_term(x)

infinite = [t for t in self.args if t.is_infinite]
infinite = [t for t in expr.args if t.is_infinite]

self = self.func(*[t.as_leading_term(x) for t in self.args]).removeO()
if not self:
expr = expr.func(*[t.as_leading_term(x) for t in expr.args]).removeO()
if not expr:
# simple leading term analysis gave us 0 but we have to send
# back a term, so compute the leading term (via series)
return old.compute_leading_term(x)
elif self is S.NaN:
elif expr is S.NaN:
return old.func._from_args(infinite)
elif not self.is_Add:
return self
elif not expr.is_Add:
return expr
else:
plain = self.func(*[s for s, _ in self.extract_leading_order(x)])
plain = expr.func(*[s for s, _ in expr.extract_leading_order(x)])
rv = factor_terms(plain, fraction=False)
rv_simplify = rv.simplify()
# if it simplifies to an x-free expression, return that;
# tests don't fail if we don't but it seems nicer to do this
if x not in rv_simplify.free_symbols:
if rv_simplify.is_zero and plain.is_zero is not True:
return (self - plain)._eval_as_leading_term(x)
return (expr - plain)._eval_as_leading_term(x)
return rv_simplify
return rv

Expand Down
8 changes: 4 additions & 4 deletions sympy/core/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def __eq__(self, other):
return False
if type(self) is not type(other):
# issue 6100 a**1.0 == a like a**2.0 == a**2
while isinstance(self, C.Pow) and self.exp == 1:
self = self.base
while isinstance(other, C.Pow) and other.exp == 1:
other = other.base
if isinstance(self, C.Pow) and self.exp == 1:
return self.base == other
if isinstance(other, C.Pow) and other.exp == 1:
return self == other.base
try:
other = _sympify(other)
except SympifyError:
Expand Down
1 change: 1 addition & 0 deletions sympy/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def __cacheit_nocache(func):
def __cacheit_debug(maxsize):
"""cacheit + code to check cache consistency"""
def func_wrapper(func):
from .decorators import wraps

cfunc = __cacheit(maxsize)(func)

Expand Down
Loading

0 comments on commit c7e7af1

Please sign in to comment.