Example #1
0
def test_has_any():
    x, y, z, t, u = symbols('x y z t u')
    f = Function("f")
    g = Function("g")
    p = Wild('p')

    assert sin(x).has(x)
    assert sin(x).has(sin)
    assert not sin(x).has(y)
    assert not sin(x).has(cos)
    assert f(x).has(x)
    assert f(x).has(f)
    assert not f(x).has(y)
    assert not f(x).has(g)

    assert f(x).diff(x).has(x)
    assert f(x).diff(x).has(f)
    assert f(x).diff(x).has(Derivative)
    assert not f(x).diff(x).has(y)
    assert not f(x).diff(x).has(g)
    assert not f(x).diff(x).has(sin)

    assert (x**2).has(Symbol)
    assert not (x**2).has(Wild)
    assert (2 * p).has(Wild)

    i = Integer(4400)

    assert i.has(x) is False

    assert (i * x**i).has(x)
    assert (i * y**i).has(x) is False
    assert (i * y**i).has(x, y)

    expr = x**2 * y + sin(2**t + log(z))

    assert expr.has(u) is False

    assert expr.has(x)
    assert expr.has(y)
    assert expr.has(z)
    assert expr.has(t)

    assert expr.has(x, y, z, t)
    assert expr.has(x, y, z, t, u)

    from sympy.physics.units import m, s

    assert (x * m / s).has(x)
    assert (x * m / s).has(y, z) is False

    poly = Poly(x**2 + x * y * sin(z), x, y, t)

    assert poly.has(x)
    assert poly.has(x, y, z)
    assert poly.has(x, y, z, t)

    assert FockState((x, y)).has(x)
Example #2
0
def test_has_any():
    x,y,z,t,u = symbols('x y z t u')
    f = Function("f")
    g = Function("g")
    p = Wild('p')

    assert sin(x).has(x)
    assert sin(x).has(sin)
    assert not sin(x).has(y)
    assert not sin(x).has(cos)
    assert f(x).has(x)
    assert f(x).has(f)
    assert not f(x).has(y)
    assert not f(x).has(g)

    assert f(x).diff(x).has(x)
    assert f(x).diff(x).has(f)
    assert f(x).diff(x).has(Derivative)
    assert not f(x).diff(x).has(y)
    assert not f(x).diff(x).has(g)
    assert not f(x).diff(x).has(sin)

    assert (x**2).has(Symbol)
    assert not (x**2).has(Wild)
    assert (2*p).has(Wild)

    i = Integer(4400)

    assert i.has(x) is False

    assert (i*x**i).has(x)
    assert (i*y**i).has(x) is False
    assert (i*y**i).has(x, y)

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has(u) is False

    assert expr.has(x)
    assert expr.has(y)
    assert expr.has(z)
    assert expr.has(t)

    assert expr.has(x, y, z, t)
    assert expr.has(x, y, z, t, u)

    from sympy.physics.units import m, s

    assert (x*m/s).has(x)
    assert (x*m/s).has(y, z) is False

    poly = Poly(x**2 + x*y*sin(z), x, y, t)

    assert poly.has(x)
    assert poly.has(x, y, z)
    assert poly.has(x, y, z, t)

    assert FockState((x, y)).has(x)
Example #3
0
def test_has_all():
    x,y,z,t,u = symbols('xyztu')
    u = symbols('u')

    i = Integer(4400)

    assert i.has(x, all=True) is False

    assert (i*x**i).has(x, all=True)
    assert (i*y**i).has(x, all=True) is False

    expr = x**2*y + sin(2**t + log(z))

    assert expr.has(y, z, t, all=True)
    assert expr.has(x, z, t, all=True)
    assert expr.has(x, y, t, all=True)
    assert expr.has(x, y, z, all=True)

    assert expr.has(y, u, t, all=True) is False
    assert expr.has(x, z, u, all=True) is False
    assert expr.has(u, y, z, all=True) is False

    assert expr.has(x, y, z, t, all=True)
    assert expr.has(x, y, z, t, u, all=True) is False

    from sympy.physics.units import m, s

    assert (x*m/s).has(x, all=True)
    assert (x*m/s).has(x, y, all=True) is False

    poly = Poly(x**2 + x*y*sin(z), x, y, t)

    assert poly.has(x, y, z, all=True)
    assert poly.has(x, y, z, t, all=True) is False

    f = FockState((x, y))
    assert f.has(x, y, all=True)
    assert f.has(x, y, z, all=True) is False
Example #4
0
def test_has_polys():
    poly = Poly(x ** 2 + x * y * sin(z), x, y, t)

    assert poly.has(x)
    assert poly.has(x, y, z)
    assert poly.has(x, y, z, t)
Example #5
0
def test_has_polys():
    poly = Poly(x**2 + x * y * sin(z), x, y, t)

    assert poly.has(x)
    assert poly.has(x, y, z)
    assert poly.has(x, y, z, t)