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


Python sympy.Le方法代码示例

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


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

示例1: __new__

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Le [as 别名]
def __new__(cls, lhs, rhs=0, subdomain=None, **kwargs):
        kwargs.update({'evaluate': False})
        obj = sympy.Le.__new__(cls, lhs, rhs, **kwargs)
        obj._subdomain = subdomain
        return obj 
开发者ID:devitocodes,项目名称:devito,代码行数:7,代码来源:relational.py

示例2: subdomain

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Le [as 别名]
def subdomain(self):
        """The SubDomain in which the Le is defined."""
        return self._subdomain 
开发者ID:devitocodes,项目名称:devito,代码行数:5,代码来源:relational.py

示例3: as_constraint

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Le [as 别名]
def as_constraint(cls, constraint, model, constraint_type=None, **init_kwargs):
        """
        Initiate a Model which should serve as a constraint. Such a
        constraint-model should be initiated with knowledge of another
        ``BaseModel``, from which it will take its parameters::

            model = Model({y: a * x + b})
            constraint = Model.as_constraint(Eq(a, 1), model)

        ``constraint.params`` will be ``[a, b]`` instead of ``[a]``.

        :param constraint: An ``Expr``, a mapping or iterable of ``Expr``, or a
            ``Relational``.
        :param model: An instance of (a subclass of)
            :class:`~symfit.core.models.BaseModel`.
        :param constraint_type: When ``constraint`` is not
            a :class:`~sympy.core.relational.Relational`, a
            :class:`~sympy.core.relational.Relational` has to be provided
            explicitly.
        :param kwargs: Any additional keyword arguments which will be passed on
            to the init method.
        """
        allowed_types = [sympy.Eq, sympy.Ge, sympy.Le]

        if isinstance(constraint, Relational):
            constraint_type = constraint.__class__
            constraint = constraint.lhs - constraint.rhs

        # Initiate the constraint model, in such a way that we take care
        # of any dependencies
        instance = cls.with_dependencies(constraint,
                                         dependency_model=model,
                                         **init_kwargs)

        # Check if the constraint_type is allowed, and flip the sign if needed
        if constraint_type not in allowed_types:
            raise ModelError(
                'Only constraints of the type {} are allowed. A constraint'
                ' of type {} was provided.'.format(allowed_types,
                                                   constraint_type)
            )
        elif constraint_type is sympy.Le:
            # We change this to a Ge and flip the sign
            instance = - instance
            constraint_type = sympy.Ge

        instance.constraint_type = constraint_type

        if len(instance.dependent_vars) != 1:
            raise ModelError('Only scalar models can be used as constraints.')

        # self.params has to be a subset of model.params
        if set(instance.params) <= set(model.params):
            instance.params = model.params
        else:
            raise ModelError('The parameters of ``constraint`` have to be a '
                             'subset of those of ``model``.')

        return instance 
开发者ID:tBuLi,项目名称:symfit,代码行数:61,代码来源:models.py


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