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


Python sympy.Interval方法代码示例

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


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

示例1: adjust_vertically_in_different_lines

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def adjust_vertically_in_different_lines(middle_y, min_graph_dist, x_factor=1., y_factor=1., *sorted_x_y_positions):
    x_y_positions = deepcopy(sorted_x_y_positions)
    for go_p, (x_pos, y_pos) in enumerate(x_y_positions):
        if go_p > 0 and (x_pos - x_y_positions[go_p - 1][0]) * x_factor < min_graph_dist:
            go_back = go_p - 1
            constraints = Interval(-inf, inf)
            while go_back >= 0 and (x_pos - x_y_positions[go_back][0]) * x_factor < min_graph_dist:
                prev_x = x_y_positions[go_back][0]
                if len(x_y_positions[go_back][1]):
                    prev_y = sum(x_y_positions[go_back][1]) / len(x_y_positions[go_back][1])
                else:
                    prev_y = 0.
                y_move = (min_graph_dist ** 2 - ((x_pos - prev_x) * x_factor) ** 2) ** 0.5 / y_factor
                constraints &= (Interval(-inf, prev_y - y_move) | Interval(prev_y + y_move, inf))
                go_back -= 1
            if middle_y not in constraints:
                new_average_y = sorted(constraints.boundary, key=lambda cons_y: abs(cons_y-middle_y))[0]
                if len(y_pos):
                    old_y = sum(y_pos) / len(y_pos)
                else:
                    old_y = 0.
                x_y_positions[go_p][1] = x_y_positions[go_p][1] - (old_y - new_average_y)
    return x_y_positions 
开发者ID:Kinggerm,项目名称:GetOrganelle,代码行数:25,代码来源:evaluate_assembly_using_mapping.py

示例2: test_logic

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def test_logic():
    x = true
    y = false
    x1 = sympy.true
    y1 = sympy.false

    assert And(x, y) == And(x1, y1)
    assert And(x1, y) == And(x1, y1)
    assert And(x, y)._sympy_() == sympy.And(x1, y1)
    assert sympify(sympy.And(x1, y1)) == And(x, y)

    assert Or(x, y) == Or(x1, y1)
    assert Or(x1, y) == Or(x1, y1)
    assert Or(x, y)._sympy_() == sympy.Or(x1, y1)
    assert sympify(sympy.Or(x1, y1)) == Or(x, y)

    assert Not(x) == Not(x1)
    assert Not(x1) == Not(x1)
    assert Not(x)._sympy_() == sympy.Not(x1)
    assert sympify(sympy.Not(x1)) == Not(x)

    assert Xor(x, y) == Xor(x1, y1)
    assert Xor(x1, y) == Xor(x1, y1)
    assert Xor(x, y)._sympy_() == sympy.Xor(x1, y1)
    assert sympify(sympy.Xor(x1, y1)) == Xor(x, y)

    x = Symbol("x")
    x1 = sympy.Symbol("x")

    assert Piecewise((x, x < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True))
    assert Piecewise((x, x1 < 1), (0, True)) == Piecewise((x1, x1 < 1), (0, True))
    assert Piecewise((x, x < 1), (0, True))._sympy_() == sympy.Piecewise((x1, x1 < 1), (0, True))
    assert sympify(sympy.Piecewise((x1, x1 < 1), (0, True))) == Piecewise((x, x < 1), (0, True))

    assert Contains(x, Interval(1, 1)) == Contains(x1, Interval(1, 1))
    assert Contains(x, Interval(1, 1))._sympy_() == sympy.Contains(x1, Interval(1, 1))
    assert sympify(sympy.Contains(x1, Interval(1, 1))) == Contains(x, Interval(1, 1)) 
开发者ID:symengine,项目名称:symengine.py,代码行数:39,代码来源:test_sympy_conv.py

示例3: test_sets

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def test_sets():
    x = Integer(2)
    y = Integer(3)
    x1 = sympy.Integer(2)
    y1 = sympy.Integer(3)

    assert Interval(x, y) == Interval(x1, y1)
    assert Interval(x1, y) == Interval(x1, y1)
    assert Interval(x, y)._sympy_() == sympy.Interval(x1, y1)
    assert sympify(sympy.Interval(x1, y1)) == Interval(x, y)

    assert sympify(sympy.S.EmptySet) == EmptySet()
    assert sympy.S.EmptySet == EmptySet()._sympy_()

    assert sympify(sympy.S.UniversalSet) == UniversalSet()
    assert sympy.S.UniversalSet == UniversalSet()._sympy_()

    assert FiniteSet(x, y) == FiniteSet(x1, y1)
    assert FiniteSet(x1, y) == FiniteSet(x1, y1)
    assert FiniteSet(x, y)._sympy_() == sympy.FiniteSet(x1, y1)
    assert sympify(sympy.FiniteSet(x1, y1)) == FiniteSet(x, y)

    x = Interval(1, 2)
    y = Interval(2, 3)
    x1 = sympy.Interval(1, 2)
    y1 = sympy.Interval(2, 3)

    assert Union(x, y) == Union(x1, y1)
    assert Union(x1, y) == Union(x1, y1)
    assert Union(x, y)._sympy_() == sympy.Union(x1, y1)
    assert sympify(sympy.Union(x1, y1)) == Union(x, y)

    assert Complement(x, y) == Complement(x1, y1)
    assert Complement(x1, y) == Complement(x1, y1)
    assert Complement(x, y)._sympy_() == sympy.Complement(x1, y1)
    assert sympify(sympy.Complement(x1, y1)) == Complement(x, y) 
开发者ID:symengine,项目名称:symengine.py,代码行数:38,代码来源:test_sympy_conv.py

示例4: __new__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def __new__(cls, interval):
        if not isinstance(interval, Interval):
            raise TypeError('L2 interval must be an Interval instance: %r'
            % interval)
        obj = Basic.__new__(cls, interval)
        return obj 
开发者ID:sympsi,项目名称:sympsi,代码行数:8,代码来源:hilbert.py

示例5: test_L2

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def test_L2():
    b1 = L2(Interval(-oo, 1))
    assert isinstance(b1, L2)
    assert b1.dimension == oo
    assert b1.interval == Interval(-oo, 1)

    x = Symbol('x', real=True)
    y = Symbol('y', real=True)
    b2 = L2(Interval(x, y))
    assert b2.dimension == oo
    assert b2.interval == Interval(x, y)
    assert b2.subs(x, -1) == L2(Interval(-1, y)) 
开发者ID:sympsi,项目名称:sympsi,代码行数:14,代码来源:test_hilbert.py

示例6: __init_finalize__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def __init_finalize__(self, name, parent, left, right, thickness, local):
        super().__init_finalize__(name, parent)
        self._interval = sympy.Interval(left, right)
        self._thickness = Thickness(*thickness)
        self._local = local 
开发者ID:devitocodes,项目名称:devito,代码行数:7,代码来源:dimension.py

示例7: _arg_values

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Interval [as 别名]
def _arg_values(self, args, interval, grid, **kwargs):
        """
        Produce a map of argument values after evaluating user input. If no user
        input is provided, get a known value in ``args`` and adjust it so that no
        out-of-bounds memory accesses will be performeed. The adjustment exploits
        the information in ``interval``, an Interval describing the Dimension data
        space. If no value is available in ``args``, use a default value.

        Parameters
        ----------
        args : dict
            Known argument values.
        interval : Interval
            Description of the Dimension data space.
        grid : Grid
            Only relevant in case of MPI execution; if ``self`` is a distributed
            Dimension, then ``grid`` is used to translate user input into rank-local
            indices.
        **kwargs
            Dictionary of user-provided argument overrides.
        """
        # Fetch user input and convert into rank-local values
        glb_minv = kwargs.pop(self.min_name, None)
        glb_maxv = kwargs.pop(self.max_name, kwargs.pop(self.name, None))
        if grid is not None and grid.is_distributed(self):
            loc_minv, loc_maxv = grid.distributor.glb_to_loc(self, (glb_minv, glb_maxv))
        else:
            loc_minv, loc_maxv = glb_minv, glb_maxv

        # If no user-override provided, use a suitable default value
        defaults = self._arg_defaults()
        if glb_minv is None:
            loc_minv = args.get(self.min_name, defaults[self.min_name])
            try:
                loc_minv -= min(interval.lower, 0)
            except (AttributeError, TypeError):
                pass
        if glb_maxv is None:
            loc_maxv = args.get(self.max_name, defaults[self.max_name])
            try:
                loc_maxv -= max(interval.upper, 0)
            except (AttributeError, TypeError):
                pass

        return {self.min_name: loc_minv, self.max_name: loc_maxv} 
开发者ID:devitocodes,项目名称:devito,代码行数:47,代码来源:dimension.py


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