本文整理汇总了Python中sympy.FiniteSet.contains方法的典型用法代码示例。如果您正苦于以下问题:Python FiniteSet.contains方法的具体用法?Python FiniteSet.contains怎么用?Python FiniteSet.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.FiniteSet
的用法示例。
在下文中一共展示了FiniteSet.contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contains
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import contains [as 别名]
def test_contains():
assert Interval(0, 2).contains(1) is S.true
assert Interval(0, 2).contains(3) is S.false
assert Interval(0, 2, True, False).contains(0) is S.false
assert Interval(0, 2, True, False).contains(2) is S.true
assert Interval(0, 2, False, True).contains(0) is S.true
assert Interval(0, 2, False, True).contains(2) is S.false
assert Interval(0, 2, True, True).contains(0) is S.false
assert Interval(0, 2, True, True).contains(2) is S.false
assert (Interval(0, 2) in Interval(0, 2)) is False
assert FiniteSet(1, 2, 3).contains(2) is S.true
assert FiniteSet(1, 2, Symbol('x')).contains(Symbol('x')) is S.true
# issue 8197
from sympy.abc import a, b
assert isinstance(FiniteSet(b).contains(-a), Contains)
assert isinstance(FiniteSet(b).contains(a), Contains)
assert isinstance(FiniteSet(a).contains(1), Contains)
raises(TypeError, lambda: 1 in FiniteSet(a))
# issue 8209
rad1 = Pow(Pow(2, S(1)/3) - 1, S(1)/3)
rad2 = Pow(S(1)/9, S(1)/3) - Pow(S(2)/9, S(1)/3) + Pow(S(4)/9, S(1)/3)
s1 = FiniteSet(rad1)
s2 = FiniteSet(rad2)
assert s1 - s2 == S.EmptySet
items = [1, 2, S.Infinity, S('ham'), -1.1]
fset = FiniteSet(*items)
assert all(item in fset for item in items)
assert all(fset.contains(item) is S.true for item in items)
assert Union(Interval(0, 1), Interval(2, 5)).contains(3) is S.true
assert Union(Interval(0, 1), Interval(2, 5)).contains(6) is S.false
assert Union(Interval(0, 1), FiniteSet(2, 5)).contains(3) is S.false
assert S.EmptySet.contains(1) is S.false
assert FiniteSet(rootof(x**3 + x - 1, 0)).contains(S.Infinity) is S.false
assert rootof(x**5 + x**3 + 1, 0) in S.Reals
assert not rootof(x**5 + x**3 + 1, 1) in S.Reals
# non-bool results
assert Union(Interval(1, 2), Interval(3, 4)).contains(x) == \
Or(And(x <= 2, x >= 1), And(x <= 4, x >= 3))
assert Intersection(Interval(1, x), Interval(2, 3)).contains(y) == \
And(y <= 3, y <= x, y >= 1, y >= 2)
assert (S.Complexes).contains(S.ComplexInfinity) == S.false
示例2: test_contains
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import contains [as 别名]
def test_contains():
assert Interval(0, 2).contains(1) is S.true
assert Interval(0, 2).contains(3) is S.false
assert Interval(0, 2, True, False).contains(0) is S.false
assert Interval(0, 2, True, False).contains(2) is S.true
assert Interval(0, 2, False, True).contains(0) is S.true
assert Interval(0, 2, False, True).contains(2) is S.false
assert Interval(0, 2, True, True).contains(0) is S.false
assert Interval(0, 2, True, True).contains(2) is S.false
assert FiniteSet(1, 2, 3).contains(2) is S.true
assert FiniteSet(1, 2, Symbol("x")).contains(Symbol("x")) is S.true
# issue 8197
from sympy.abc import a, b
assert isinstance(FiniteSet(b).contains(-a), Contains)
assert isinstance(FiniteSet(b).contains(a), Contains)
assert isinstance(FiniteSet(a).contains(1), Contains)
raises(TypeError, lambda: 1 in FiniteSet(a))
# issue 8209
rad1 = Pow(Pow(2, S(1) / 3) - 1, S(1) / 3)
rad2 = Pow(S(1) / 9, S(1) / 3) - Pow(S(2) / 9, S(1) / 3) + Pow(S(4) / 9, S(1) / 3)
s1 = FiniteSet(rad1)
s2 = FiniteSet(rad2)
assert s1 - s2 == S.EmptySet
items = [1, 2, S.Infinity, S("ham"), -1.1]
fset = FiniteSet(*items)
assert all(item in fset for item in items)
assert all(fset.contains(item) is S.true for item in items)
assert Union(Interval(0, 1), Interval(2, 5)).contains(3) is S.true
assert Union(Interval(0, 1), Interval(2, 5)).contains(6) is S.false
assert Union(Interval(0, 1), FiniteSet(2, 5)).contains(3) is S.false
assert S.EmptySet.contains(1) is S.false
assert FiniteSet(RootOf(x ** 3 + x - 1, 0)).contains(S.Infinity) is S.false
assert RootOf(x ** 5 + x ** 3 + 1, 0) in S.Reals
assert not RootOf(x ** 5 + x ** 3 + 1, 1) in S.Reals
示例3: test_contains
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import contains [as 别名]
def test_contains():
assert Interval(0, 2).contains(1) == True
assert Interval(0, 2).contains(3) == False
assert Interval(0, 2, True, False).contains(0) == False
assert Interval(0, 2, True, False).contains(2) == True
assert Interval(0, 2, False, True).contains(0) == True
assert Interval(0, 2, False, True).contains(2) == False
assert Interval(0, 2, True, True).contains(0) == False
assert Interval(0, 2, True, True).contains(2) == False
assert FiniteSet(1,2,3).contains(2)
assert FiniteSet(1,2,Symbol('x')).contains(Symbol('x'))
items = [1, 2, S.Infinity, S('ham'), -1.1]
fset = FiniteSet(*items)
assert all(item in fset for item in items)
assert all(fset.contains(item) is True for item in items)
assert Union(Interval(0, 1), Interval(2, 5)).contains(3) == True
assert Union(Interval(0, 1), Interval(2, 5)).contains(6) == False
assert Union(Interval(0, 1), FiniteSet(2, 5)).contains(3) == False
assert S.EmptySet.contains(1) == False