本文整理汇总了Python中sympy.core.logic.fuzzy_or函数的典型用法代码示例。如果您正苦于以下问题:Python fuzzy_or函数的具体用法?Python fuzzy_or怎么用?Python fuzzy_or使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fuzzy_or函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fuzzy_or
def test_fuzzy_or():
assert fuzzy_or([T, T]) == T
assert fuzzy_or([T, F]) == T
assert fuzzy_or([T, U]) == T
assert fuzzy_or([F, F]) == F
assert fuzzy_or([F, U]) == U
assert fuzzy_or([U, U]) == U
assert [fuzzy_or([w]) for w in [U, T, F]] == [U, T, F]
assert fuzzy_or([T, F, U]) == T
assert fuzzy_or([]) == F
raises(TypeError, lambda: fuzzy_or())
示例2: is_monotonic
def is_monotonic(f, interval=S.Reals, symbol=None):
"""
Returns if a function is monotonic or not, in the given
``Interval``.
Examples
========
>>> from sympy import is_monotonic
>>> from sympy.abc import x, y
>>> from sympy import S, Interval, oo
>>> is_monotonic(1/(x**2 - 3*x), Interval.open(1.5, 3))
True
>>> is_monotonic(1/(x**2 - 3*x), Interval.Lopen(3, oo))
True
>>> is_monotonic(x**3 - 3*x**2 + 4*x, S.Reals)
True
>>> is_monotonic(-x**2, S.Reals)
False
>>> is_monotonic(x**2 + y + 1, Interval(1, 2), x)
True
"""
from sympy.core.logic import fuzzy_or
f = sympify(f)
free_sym = f.free_symbols
if symbol is None and len(free_sym) > 1:
raise NotImplementedError('is_monotonic has not yet been '
'for all multivariate expressions')
inc = is_increasing(f, interval, symbol)
dec = is_decreasing(f, interval, symbol)
return fuzzy_or([inc, dec])
示例3: is_monotonic
def is_monotonic(f, interval=S.Reals):
"""
Returns if a function is monotonic or not, in the given
``Interval``.
Examples
========
>>> from sympy import is_monotonic
>>> from sympy.abc import x
>>> from sympy import S, Interval, oo
>>> is_monotonic(1/(x**2 - 3*x), Interval.open(1.5, 3))
True
>>> is_monotonic(1/(x**2 - 3*x), Interval.Lopen(3, oo))
True
>>> is_monotonic(x**3 - 3*x**2 + 4*x, S.Reals)
True
>>> is_monotonic(-x**2, S.Reals)
False
"""
from sympy.core.logic import fuzzy_or
if len(f.free_symbols) > 1:
raise NotImplementedError('is_monotonic has not yet been '
'implemented for multivariate expressions')
inc = is_increasing(f, interval)
dec = is_decreasing(f, interval)
return fuzzy_or([inc, dec])
示例4: Basic
def Basic(expr, assumptions):
if expr.is_number:
# if there are no symbols just evalf
i = expr.evalf(2)
def nonz(i):
if i._prec != 1:
return i != 0
return fuzzy_or(nonz(i) for i in i.as_real_imag())
示例5: _old_assump_replacer
def _old_assump_replacer(obj):
# Things to be careful of:
# - real means real or infinite in the old assumptions.
# - nonzero does not imply real in the old assumptions.
# - finite means finite and not zero in the old assumptions.
if not isinstance(obj, AppliedPredicate):
return obj
e = obj.args[0]
ret = None
if obj.func == Q.positive:
ret = fuzzy_and([e.is_finite, e.is_positive])
if obj.func == Q.zero:
ret = e.is_zero
if obj.func == Q.negative:
ret = fuzzy_and([e.is_finite, e.is_negative])
if obj.func == Q.nonpositive:
ret = fuzzy_and([e.is_finite, e.is_nonpositive])
if obj.func == Q.nonzero:
ret = fuzzy_and([e.is_nonzero, e.is_finite])
if obj.func == Q.nonnegative:
ret = fuzzy_and([fuzzy_or([e.is_zero, e.is_finite]),
e.is_nonnegative])
if obj.func == Q.rational:
ret = e.is_rational
if obj.func == Q.irrational:
ret = e.is_irrational
if obj.func == Q.even:
ret = e.is_even
if obj.func == Q.odd:
ret = e.is_odd
if obj.func == Q.integer:
ret = e.is_integer
if obj.func == Q.imaginary:
ret = e.is_imaginary
if obj.func == Q.commutative:
ret = e.is_commutative
if ret is None:
return obj
return ret
示例6: _eval_is_zero
def _eval_is_zero(self):
# is_imaginary implies nonzero
return fuzzy_or([self.args[0].is_imaginary, self.args[0].is_zero])
示例7: Mul
def Mul(expr, assumptions):
# TODO: This should be deducible from the nonzero handler
return fuzzy_or(ask(Q.zero(arg), assumptions) for arg in expr.args)
示例8: _eval_is_negative
def _eval_is_negative(self):
return fuzzy_or(a.is_negative for a in self.args)