Skip to content

Commit

Permalink
Add regression tests & mention closed issues
Browse files Browse the repository at this point in the history
    close sympy/sympy#3112 (MrvAsympt was added in diofant#6)
    close sympy/sympy#9173 (test was added in 5a510ac)
    close sympy/sympy#9808 (fixed in 09e539b)
    close sympy/sympy#9341 (fixed in af98a00)
    close sympy/sympy#9908 (fixed in cc3fa8d)
    close sympy/sympy#6171 (test added in d278031)
    close sympy/sympy#9276 (diagnose_imports.py removed in ab8c535)
    close sympy/sympy#10201 (fixed in 0d0fc5f)
    close sympy/sympy#9057 (test was added in 8290a0c)
    close sympy/sympy#11159 (test was added in ffb76cb)
    close sympy/sympy#2839 (new AST transformers are used, see diofant#278 and diofant#167)
    close sympy/sympy#11081 (see ed01e16 and bb92329)
    close sympy/sympy#10974 (see 73fc425)
    close sympy/sympy#10806 (test in 539929a)
    close sympy/sympy#10801 (test in 2fe3da5)
    close sympy/sympy#9549 (test in 88bdefa)
    close sympy/sympy#4231 (test was added in fb411d5)
    close sympy/sympy#8634 (see 2fcbb58)
    close sympy/sympy#8481 (see 1ef20d3)
    close sympy/sympy#9956 (fixed in a34735f)
    close sympy/sympy#9747 (see e117c60)
    close sympy/sympy#7853 (see 3e4fbed)
    close sympy/sympy#9634 (see 2be03f5)
    close sympy/sympy#8500 (fixed in diofant#104 and finally in diofant#316)
    close sympy/sympy#9192 (see 9bf622f)
    close sympy/sympy#7130 (see e068fa3)
    close sympy/sympy#8514 (see b2d543b)
    close sympy/sympy#9334 (see 90de625)
    close sympy/sympy#8229 (see 9755b89)
    close sympy/sympy#8061 (see 7054f06)
    close sympy/sympy#7872 (tested in diofant#6)
    close sympy/sympy#3496 (tested in test_log_symbolic)
    close sympy/sympy#2929 (see da7db7a)
    close sympy/sympy#8203 (oo is not a real, see diofant#36)
    close sympy/sympy#7649 (0 is imaginary since diofant#8)
    close sympy/sympy#7256 (fixed in c0a4549)
    close sympy/sympy#6783 (see cb28d63)
    close sympy/sympy#5662 (is_integer issue fixed in 6bfa9f8, there is no is_bounded anymore)
    close sympy/sympy#5295 (fixed with diofant#354)
    close sympy/sympy#4856 (we now have flake/pep tests)
    close sympy/sympy#4555 (flake8 enabled after diofant#214)
    close sympy/sympy#5773 (cmp_to_key removed after diofant#164 and c9acbf0)
    close sympy/sympy#5484 (see above)

    Added regression tests:
    from https://groups.google.com/forum/#!topic/sympy/LkTMQKC_BOw
    fixes sympy/sympy#8825 (probably via diofant#209)
    fixes sympy/sympy#8635
    fixes sympy/sympy#8157
    fixes sympy/sympy#7872
    fixes sympy/sympy#7599
    fixes sympy/sympy#6179
    fixes sympy/sympy#5415
    fixes sympy/sympy#2865
    fixes sympy/sympy#5907
    fixes sympy/sympy#11722

    Closes diofant#347
  • Loading branch information
skirpichev committed Nov 2, 2016
1 parent 4b91ea3 commit 48c035e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 6 deletions.
25 changes: 22 additions & 3 deletions diofant/core/tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest

from diofant.core.symbol import Symbol
from diofant.core.compatibility import ordered
from diofant.core.symbol import Symbol, symbols
from diofant.core.cache import cacheit, CACHE, print_cache, clear_cache
from diofant.printing.str import sstr

from diofant.abc import x

Expand Down Expand Up @@ -68,7 +70,7 @@ def test_nocache(clear_imports, monkeypatch):
monkeypatch.setenv('DIOFANT_USE_CACHE', 'False')
from diofant.core.cache import CACHE
from diofant.core.symbol import Symbol
from diofant.functions import sin, sqrt
from diofant.functions import sin, sqrt, exp, sinh

# test that we don't use cache
assert CACHE == []
Expand All @@ -82,7 +84,7 @@ def test_nocache(clear_imports, monkeypatch):
(2*x).is_complex # not raises

# see commit c459d18
sin(x + x)
sin(x + x) # not raises

# see commit 53dd1eb
mx = -Symbol('x', negative=False)
Expand All @@ -96,3 +98,20 @@ def test_nocache(clear_imports, monkeypatch):
y = Symbol('y')
result = s.subs(sqrt(x**2), y)
assert result == 1/y

# problem from https://groups.google.com/forum/#!topic/sympy/LkTMQKC_BOw
# see commit c459d18
a = Symbol('a', positive=True)
f = exp(x*(-a - 1))
g = sinh(x)
r = f*g # not raises


def test_issue_8825():
import weakref
a, b = symbols('a b')
d = weakref.WeakKeyDictionary([(a, 1), (b, 2)])
assert sstr(list(ordered(d.items()))) == '[(a, 1), (b, 2)]'
del a
clear_cache()
assert sstr(list(ordered(d.items()))) == '[(b, 2)]'
7 changes: 7 additions & 0 deletions diofant/integrals/tests/test_integrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,13 @@ def test_issue_5413():
assert integrate(-a/(a**2 + x**2), x) == I*log(-I*a + x)/2 - I*log(I*a + x)/2


def test_issue_5907():
a = Symbol('a', real=True)
assert (integrate(1/(x**2 + a**2)**2, x) ==
x/(2*a**4 + 2*a**2*x**2) + (-I*log(-I*a + x)/4 +
I*log(I*a + x)/4)/a**3)


def test_issue_4892a():
A = symbols('A')
c = Symbol('c', nonzero=True)
Expand Down
37 changes: 36 additions & 1 deletion diofant/series/tests/test_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
acos, ceiling, atan, gamma, Symbol, S, pi, E, Integral,
cot, Rational, I, tan, integrate, Sum, sign, Piecewise,
Function, subfactorial, PoleError, Integer, Float,
diff, simplify, Matrix)
diff, simplify, Matrix, sinh, polygamma)
from diofant.series.limits import heuristics
from diofant.series.order import O

Expand Down Expand Up @@ -104,6 +104,12 @@ def eval(cls, arg):
return S.NaN
assert limit(my(x), x, oo) == Limit(my(x), x, oo)

# from https://groups.google.com/forum/#!topic/sympy/LkTMQKC_BOw
# fix bisected to ade6d20 and c459d18
a = Symbol('a', positive=True)
f = exp(x*(-a - 1)) * sinh(x)
assert limit(f, x, oo) == 0


def test_issue_3885():
assert limit(x*y + x*z, z, 2) == x*y + 2*x
Expand Down Expand Up @@ -501,3 +507,32 @@ def test_issue_11678():
assert e == Matrix([[Float('0.36363636363636359', prec=15),
Float('0.090909090909090898', prec=15),
Float('0.54545454545454541', prec=15)]]*3)


def test_issue_8635():
n = Symbol('n', integer=True, positive=True)

k = 0
assert limit(x**n - x**(n - k), x, oo) == 0
k = 1
assert limit(x**n - x**(n - k), x, oo) == oo
k = 2
assert limit(x**n - x**(n - k), x, oo) == oo
k = 3
assert limit(x**n - x**(n - k), x, oo) == oo


def test_issue_8157():
n = Symbol('n', integer=True)
limit(cos(pi*n), n, oo) # not raises


def test_issue_5415():
assert limit(polygamma(2 + 1/x, 3 + exp(-x)), x, oo) == polygamma(2, 3)


def test_issue_2865():
l1 = limit(O(1/x, (x, oo)), x, 0)
assert l1 != 0 and isinstance(l1, Limit)
l2 = limit(O(x, (x, oo)), x, 0)
assert l2 != 0 and isinstance(l2, Limit)
10 changes: 8 additions & 2 deletions diofant/series/tests/test_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from diofant import (Symbol, Rational, exp, ln, log, nan, oo, O, pi, I,
from diofant import (Symbol, Rational, exp, ln, log, nan, oo, O, pi, I, Add,
Integral, sin, cos, sqrt, conjugate, expand, transpose,
symbols, Function, Derivative, Integer, digamma)

Expand Down Expand Up @@ -335,7 +335,8 @@ def test_issue_6753():


def test_issue_7872():
assert O(x**3).subs(x, exp(-x**2)) == O(exp(-3*x**2), (x, -oo))
assert O(x**3).subs(x, exp(-x**2)) in [O(exp(-3*x**2), (x, oo)),
O(exp(-3*x**2), (x, -oo))]


def test_order_at_infinity():
Expand Down Expand Up @@ -421,3 +422,8 @@ def test_issue_9351():
def test_issue_9192():
assert O(1)*O(1) == O(1)
assert O(1)**O(1) == O(1)


def test_issue_7599():
n = Symbol('n', integer=True)
assert O(x**n, x) + O(x**2) == Add(O(x**2), O(x**n, x), evaluate=False)
15 changes: 15 additions & 0 deletions diofant/series/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,18 @@ def test_issue_11407():
a, b, c = symbols('a, b, c')
assert sqrt(a + b + c*x).series(x, 0, 1) == sqrt(a + b) + O(x)
assert sqrt(a + b + c + c*x).series(x, 0, 1) == sqrt(a + b + c) + O(x)


def test_issue_6179():
assert (sin(x)*log(x)).series(x, 0, 4) == (x*log(x) -
x**3*log(x)/6 + O(x**4))
assert ((x**2*(x**3 + x**2 + 1)*log(x)).series(x, 0, 4) ==
x**2*log(x) + x**4*log(x) + O(x**4))


@pytest.mark.slow
def test_issue_11722():
t, g = symbols('t g')
good = -g**4*t**4/4 + 7*g**3*t**4/3 + g**3*t**3/3 - 27*g**2*t**4/4 - 2*g**2*t**3 - g**2*t**2/2 + 15*g*t**4/2 + 19*g*t**3/6 + 3*g*t**2/2 + g*t + g - 2009*t**4/720 - 13*t**3/9 - 5*t**2/6 - t/2 - (g + log(-t + 1) - 1 + (g + log(-t + 1))/(-1 + 1/t) - 1/(2*(-1 + 1/t)) - (g + log(-t + 1))**2/(2*(-1 + 1/t)**2) + 3*(g + log(-t + 1))/(2*(-1 + 1/t)**2) - 5/(6*(-1 + 1/t)**2) + (g + log(-t + 1))**3/(3*(-1 + 1/t)**3) - 2*(g + log(-t + 1))**2/(-1 + 1/t)**3 + 19*(g + log(-t + 1))/(6*(-1 + 1/t)**3) - 13/(9*(-1 + 1/t)**3) - (g + log(-t + 1))**4/(4*(-1 + 1/t)**4) + 7*(g + log(-t + 1))**3/(3*(-1 + 1/t)**4) - 27*(g + log(-t + 1))**2/(4*(-1 + 1/t)**4) + 15*(g + log(-t + 1))/(2*(-1 + 1/t)**4) - 2009/(720*(-1 + 1/t)**4) + 1/t)/(1 - 1/(g + log(-t + 1) - 1 + (g + log(-t + 1))/(-1 + 1/t) - 1/(2*(-1 + 1/t)) - (g + log(-t + 1))**2/(2*(-1 + 1/t)**2) + 3*(g + log(-t + 1))/(2*(-1 + 1/t)**2) - 5/(6*(-1 + 1/t)**2) + (g + log(-t + 1))**3/(3*(-1 + 1/t)**3) - 2*(g + log(-t + 1))**2/(-1 + 1/t)**3 + 19*(g + log(-t + 1))/(6*(-1 + 1/t)**3) - 13/(9*(-1 + 1/t)**3) - (g + log(-t + 1))**4/(4*(-1 + 1/t)**4) + 7*(g + log(-t + 1))**3/(3*(-1 + 1/t)**4) - 27*(g + log(-t + 1))**2/(4*(-1 + 1/t)**4) + 15*(g + log(-t + 1))/(2*(-1 + 1/t)**4) - 2009/(720*(-1 + 1/t)**4) + 1/t)) + 1/t
bad = good.subs(g, log(1/t))
assert bad.series(t, x0=0, n=5) == O(t**5)

0 comments on commit 48c035e

Please sign in to comment.