当前位置: 首页>>代码示例>>Python>>正文


Python FiniteSet.intersect方法代码示例

本文整理汇总了Python中sympy.FiniteSet.intersect方法的典型用法代码示例。如果您正苦于以下问题:Python FiniteSet.intersect方法的具体用法?Python FiniteSet.intersect怎么用?Python FiniteSet.intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.FiniteSet的用法示例。


在下文中一共展示了FiniteSet.intersect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_finite_basic

# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import intersect [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 A.is_subset(AorB) and B.is_subset(AorB)
    assert AandB.is_subset(A)
    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)

    # issue 7335
    assert FiniteSet(S.EmptySet) != S.EmptySet
    assert FiniteSet(FiniteSet(1, 2, 3)) != FiniteSet(1, 2, 3)
    assert FiniteSet((1, 2, 3)) != FiniteSet(1, 2, 3)

    # 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
开发者ID:baruchel,项目名称:sympy,代码行数:34,代码来源:test_sets.py

示例2: test_finite_basic

# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import intersect [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)
开发者ID:piyushbansal,项目名称:sympy,代码行数:19,代码来源:test_sets.py

示例3: FiniteSet

# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import intersect [as 别名]
from sympy import FiniteSet, pi
# Unions & Intersections
s = FiniteSet(1, 2, 3)
t = FiniteSet(2, 4, 6)

union = s.union(t)
print(union)

intersection = s.intersect(t)
print(intersection)

### Cartesian Products
cartesianProduct = s * t
print(cartesianProduct)

for elem in cartesianProduct:
    print(elem)

# Raise set to the power (calculate triplets)
cartesianProductCubed = s ** 3
for elem in cartesianProductCubed:
    print(elem)




def time_period(length, g):
    T = 2*pi*(length/g)**0.5
    return T

L = FiniteSet(15, 18, 21, 22.5, 25)
开发者ID:JSONMartin,项目名称:codingChallenges,代码行数:33,代码来源:sympy_operations.py

示例4: FiniteSet

# 需要导入模块: from sympy import FiniteSet [as 别名]
# 或者: from sympy.FiniteSet import intersect [as 别名]
# 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


# Calculando el producto cartesiano. 
A = FiniteSet(1, 2)
B = FiniteSet(3, 4)
P = A * B
for elem in P:
    print(elem)
    
    
# Calcula el n producto cartesiano del mismo conjunto.
开发者ID:josearcosaneas,项目名称:Matematicas-con-Python,代码行数:32,代码来源:conjuntos.py


注:本文中的sympy.FiniteSet.intersect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。