本文整理汇总了Python中sympy.FiniteSet.subset方法的典型用法代码示例。如果您正苦于以下问题:Python FiniteSet.subset方法的具体用法?Python FiniteSet.subset怎么用?Python FiniteSet.subset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.FiniteSet
的用法示例。
在下文中一共展示了FiniteSet.subset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_finite_basic
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import subset [as 别名]
def test_finite_basic():
x = Symbol('x')
A = FiniteSet(1, 2, 3)
B = FiniteSet(3, 4, 5)
AorB = Union(A, B)
AandB = A.intersect(B)
assert AorB.subset(A) and AorB.subset(B)
assert A.subset(AandB)
assert AandB == FiniteSet(3)
assert A.inf == 1 and A.sup == 3
assert AorB.inf == 1 and AorB.sup == 5
assert FiniteSet(x, 1, 5).sup == Max(x, 5)
assert FiniteSet(x, 1, 5).inf == Min(x, 1)
# Ensure a variety of types can exist in a FiniteSet
S = FiniteSet((1, 2), Float, A, -5, x, 'eggs', x**2, Interval)
assert (A > B) is False
assert (A >= B) is False
assert (A < B) is False
assert (A <= B) is False
assert AorB > A and AorB > B
assert AorB >= A and AorB >= B
assert A >= A and A <= A
assert A >= AandB and B >= AandB
assert A > AandB and B > AandB
示例2: test_finite_basic
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import subset [as 别名]
def test_finite_basic():
x = Symbol("x")
A = FiniteSet(1, 2, 3)
B = FiniteSet(3, 4, 5)
AorB = Union(A, B)
AandB = A.intersect(B)
assert AorB.subset(A) and AorB.subset(B)
assert A.subset(AandB)
assert AandB == FiniteSet(3)
assert A.inf == 1 and A.sup == 3
assert AorB.inf == 1 and AorB.sup == 5
assert FiniteSet(x, 1, 5).sup == Max(x, 5)
assert FiniteSet(x, 1, 5).inf == Min(x, 1)
# Ensure a variety of types can exist in a FiniteSet
S = FiniteSet((1, 2), Float, A, -5, x, "eggs", x ** 2, Interval)
示例3: FiniteSet
# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import subset [as 别名]
# Diferencia entre conjuntos
print A - B
print B - A
"""
Conjunto y operaciones con conjuntos usando la libreria SYMPY
"""
# Utilizando FiniteSet de sympy
from sympy import FiniteSet
C = FiniteSet(1, 2, 3)
# Subconjunto y subconjunto propio
A = FiniteSet(1,2,3)
B = FiniteSet(1,2,3,4,5)
A.subset(B)
# Union de dos conjuntos
A = FiniteSet(1, 2, 3)
B = FiniteSet(2, 4, 6)
A.union(B)
# Interseccion de dos conjuntos
A = FiniteSet(1, 2)
B = FiniteSet(2, 3)
A.intersect(B)
# Diferencia entre conjuntos
print A - B