Esempio n. 1
0
def test_print_cache(capfd):
    clear_cache()
    _identity(x)
    info = _identity.cache_info()
    print_cache()
    resout, _ = capfd.readouterr()
    assert resout.find('_identity ' + str(info)) >= 0
Esempio n. 2
0
def test_print_cache(capfd):
    clear_cache()
    _identity(x)
    info = _identity.cache_info()
    print_cache()
    resout, _ = capfd.readouterr()
    assert resout.find('_identity ' + str(info)) >= 0
Esempio n. 3
0
def test_sympyissue_8825():
    t1, t2 = symbols('t1:3')
    d = weakref.WeakKeyDictionary([(t1, 1), (t2, 2)])
    assert sstr(list(ordered(d.items()))) == '[(t1, 1), (t2, 2)]'
    del t1
    clear_cache()
    gc.collect()
    assert sstr(list(ordered(d.items()))) == '[(t2, 2)]'
Esempio n. 4
0
def test_sympyissue_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)]'
Esempio n. 5
0
def test_sympyissue_8825():
    t1, t2 = symbols('t1:3')
    d = weakref.WeakKeyDictionary([(t1, 1), (t2, 2)])
    assert sstr(list(ordered(d.items()))) == '[(t1, 1), (t2, 2)]'
    del t1
    clear_cache()
    gc.collect()
    assert sstr(list(ordered(d.items()))) == '[(t2, 2)]'
Esempio n. 6
0
def test_pow_eval_subs_no_cache():
    s = 1 / sqrt(x**2)
    # This bug only appeared when the cache was turned off.
    clear_cache()

    # This used to fail with a wrong result.
    # It incorrectly returned 1/sqrt(x**2) before.
    result = s.subs({sqrt(x**2): y})
    assert result == 1 / y
Esempio n. 7
0
def test_sympyissue_7688():
    f = Function('f')  # actually an UndefinedFunction
    clear_cache()

    class A(UndefinedFunction):
        pass

    a = A('f')
    assert isinstance(a, type(f))
Esempio n. 8
0
def test_sympyissue_7687():
    f = Function('f')(x)
    ff = Function('f')(x)
    match_with_cache = f.match(ff)
    assert isinstance(f, type(ff))
    clear_cache()
    ff = Function('f')(x)
    assert isinstance(f, type(ff))
    assert match_with_cache == f.match(ff)
Esempio n. 9
0
def test_pow_eval_subs_no_cache():
    s = 1/sqrt(x**2)
    # This bug only appeared when the cache was turned off.
    clear_cache()

    # This used to fail with a wrong result.
    # It incorrectly returned 1/sqrt(x**2) before.
    result = s.subs({sqrt(x**2): y})
    assert result == 1/y
Esempio n. 10
0
def test_sympyissue_7688():
    f = Function('f')  # actually an UndefinedFunction
    clear_cache()

    class A(UndefinedFunction):
        pass

    a = A('f')
    assert isinstance(a, type(f))
Esempio n. 11
0
def test_sympyissue_7687():
    f = Function('f')(x)
    ff = Function('f')(x)
    match_with_cache = f.match(ff)
    assert isinstance(f, type(ff))
    clear_cache()
    ff = Function('f')(x)
    assert isinstance(f, type(ff))
    assert match_with_cache == f.match(ff)
Esempio n. 12
0
def test_sympyissue_7688():
    from diofant.core.function import Function, UndefinedFunction

    f = Function('f')  # actually an UndefinedFunction
    clear_cache()

    class A(UndefinedFunction):
        pass

    a = A('f')
    assert isinstance(a, type(f))
Esempio n. 13
0
def test_sympyissue_7687():
    from diofant.core.function import Function
    from diofant.abc import x
    f = Function('f')(x)
    ff = Function('f')(x)
    match_with_cache = ff.matches(f)
    assert isinstance(f, type(ff))
    clear_cache()
    ff = Function('f')(x)
    assert isinstance(f, type(ff))
    assert match_with_cache == ff.matches(f)
Esempio n. 14
0
def test_print_cache(capfd):
    clear_cache()
    wrapped = _identity.__wrapped__
    _identity(x)
    item = str(wrapped)
    head = '='*len(item)
    res = (head + "\n" + item + "\n" + head + "\n" +
           "  ((Symbol('x'), <class 'diofant.core.symbol.Symbol'>), (True,)) : x\n")
    print_cache()
    resout, _ = capfd.readouterr()
    assert resout == res
    assert dict(CACHE)[wrapped] == {((x, Symbol), (True,)): x}
Esempio n. 15
0
def file_clear_cache():
    clear_cache()