本文整理汇总了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
示例2: subdomain
# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import Le [as 别名]
def subdomain(self):
"""The SubDomain in which the Le is defined."""
return self._subdomain
示例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