本文整理匯總了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