modelparameters.sympy.assumptions.handlers package¶
Submodules¶
modelparameters.sympy.assumptions.handlers.calculus module¶
This module contains query handlers responsible for calculus queries: infinitesimal, finite, etc.
- class modelparameters.sympy.assumptions.handlers.calculus.AskFiniteHandler[source]¶
Bases:
CommonHandler
Handler for key ‘finite’.
Test that an expression is bounded respect to all its variables.
Examples of usage:
>>> from ... import Symbol, Q >>> from .calculus import AskFiniteHandler >>> from ...abc import x >>> a = AskFiniteHandler() >>> a.Symbol(x, Q.positive(x)) == None True >>> a.Symbol(x, Q.finite(x)) True
- static Add(expr, assumptions)[source]¶
Return True if expr is bounded, False if not and None if unknown.
Truth Table:
B
U
?
‘+’
‘-’
‘x’
‘+’
‘-’
‘x’
B
B
U
?
U
‘+’
U
?
?
U
?
?
‘-’
?
U
?
?
U
?
‘x’
?
?
?
?
‘B’ = Bounded
‘U’ = Unbounded
‘?’ = unknown boundedness
‘+’ = positive sign
‘-’ = negative sign
‘x’ = sign unknown
All Bounded -> True
1 Unbounded and the rest Bounded -> False
>1 Unbounded, all with same known sign -> False
Any Unknown and unknown sign -> None
Else -> None
When the signs are not the same you can have an undefined result as in oo - oo, hence ‘bounded’ is also undefined.
- static Exp1(expr, assumptions)¶
- static GoldenRatio(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)[source]¶
Return True if expr is bounded, False if not and None if unknown.
Truth Table:
B
U
?
s
/s
B
B
U
?
U
U
U
?
?
?
B = Bounded
U = Unbounded
? = unknown boundedness
s = signed (hence nonzero)
/s = not signed
- static NegativeInfinity(expr, assumptions)¶
- static Number(expr, assumptions)¶
- static Pi(expr, assumptions)¶
- static Pow(expr, assumptions)[source]¶
Unbounded ** NonZero -> Unbounded Bounded ** Bounded -> Bounded Abs()<=1 ** Positive -> Bounded Abs()>=1 ** Negative -> Bounded Otherwise unknown
- static Symbol(expr, assumptions)[source]¶
Handles Symbol.
Examples
>>> from ... import Symbol, Q >>> from .calculus import AskFiniteHandler >>> from ...abc import x >>> a = AskFiniteHandler() >>> a.Symbol(x, Q.positive(x)) == None True >>> a.Symbol(x, Q.finite(x)) True
- static cos(expr, assumptions)¶
- static exp(expr, assumptions)¶
- static sign(expr, assumptions)¶
- static sin(expr, assumptions)¶
modelparameters.sympy.assumptions.handlers.common module¶
- class modelparameters.sympy.assumptions.handlers.common.AskCommutativeHandler[source]¶
Bases:
CommonHandler
Handler for key ‘commutative’
- static NaN(expr, assumptions)¶
- static Number(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.common.AskHandler[source]¶
Bases:
object
Base class that all Ask Handlers must inherit
- class modelparameters.sympy.assumptions.handlers.common.CommonHandler[source]¶
Bases:
AskHandler
Defines some useful methods common to most Handlers
- static NaN(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.common.TautologicalHandler[source]¶
Bases:
AskHandler
Wrapper allowing to query the truth value of a boolean expression.
- static BooleanFalse(expr, assumptions)¶
- static BooleanTrue(expr, assumptions)¶
modelparameters.sympy.assumptions.handlers.matrices module¶
This module contains query handlers responsible for calculus queries: infinitesimal, bounded, etc.
- class modelparameters.sympy.assumptions.handlers.matrices.AskComplexElementsHandler[source]¶
Bases:
CommonHandler
- static BlockMatrix(expr, assumptions)¶
Block Matrix elements
- static DFT(expr, assumptions)¶
- static Determinant(expr, assumptions)¶
- static Factorization(expr, assumptions)¶
- static HadamardProduct(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static MatMul(expr, assumptions)¶
- static MatrixSlice(expr, assumptions)¶
Matrix Slice elements
- static Trace(expr, assumptions)¶
- static Transpose(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskDiagonalHandler[source]¶
Bases:
CommonHandler
Handler for key ‘diagonal’
- static Factorization(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskFullRankHandler[source]¶
Bases:
CommonHandler
Handler for key ‘fullrank’
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskIntegerElementsHandler[source]¶
Bases:
CommonHandler
- static BlockMatrix(expr, assumptions)¶
Block Matrix elements
- static Determinant(expr, assumptions)¶
- static HadamardProduct(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static MatMul(expr, assumptions)¶
- static MatrixSlice(expr, assumptions)¶
Matrix Slice elements
- static Trace(expr, assumptions)¶
- static Transpose(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskInvertibleHandler[source]¶
Bases:
CommonHandler
Handler for key ‘invertible’
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskLowerTriangularHandler[source]¶
Bases:
CommonHandler
Handler for key ‘lower_triangular’
- static Factorization(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskOrthogonalHandler[source]¶
Bases:
CommonHandler
Handler for key ‘orthogonal’
- static Factorization(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- predicate = Q.orthogonal¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskPositiveDefiniteHandler[source]¶
Bases:
CommonHandler
Handler for key ‘positive_definite’
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskRealElementsHandler[source]¶
Bases:
CommonHandler
- static BlockMatrix(expr, assumptions)¶
Block Matrix elements
- static Determinant(expr, assumptions)¶
- static Factorization(expr, assumptions)¶
- static HadamardProduct(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static MatMul(expr, assumptions)¶
- static MatrixSlice(expr, assumptions)¶
Matrix Slice elements
- static Trace(expr, assumptions)¶
- static Transpose(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskSquareHandler[source]¶
Bases:
CommonHandler
Handler for key ‘square’
- class modelparameters.sympy.assumptions.handlers.matrices.AskSymmetricHandler[source]¶
Bases:
CommonHandler
Handler for key ‘symmetric’
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskUnitaryHandler[source]¶
Bases:
CommonHandler
Handler for key ‘unitary’
- static Factorization(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static Inverse(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- predicate = Q.unitary¶
- class modelparameters.sympy.assumptions.handlers.matrices.AskUpperTriangularHandler[source]¶
Bases:
CommonHandler
Handler for key ‘upper_triangular’
- static Factorization(expr, assumptions)¶
- static Identity(expr, assumptions)¶
- static ZeroMatrix(expr, assumptions)¶
- modelparameters.sympy.assumptions.handlers.matrices.BM_elements(predicate, expr, assumptions)[source]¶
Block Matrix elements
modelparameters.sympy.assumptions.handlers.ntheory module¶
Handlers for keys related to number theory: prime, even, odd, etc.
- class modelparameters.sympy.assumptions.handlers.ntheory.AskCompositeHandler[source]¶
Bases:
CommonHandler
- class modelparameters.sympy.assumptions.handlers.ntheory.AskEvenHandler[source]¶
Bases:
CommonHandler
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)[source]¶
Even * Integer -> Even Even * Odd -> Even Integer * Odd -> ? Odd * Odd -> Odd Even * Even -> Even Integer * Integer -> Even if Integer + Integer = Odd
-> ? otherwise
- static NegativeInfinity(expr, assumptions)¶
- static Rational(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.ntheory.AskOddHandler[source]¶
Bases:
CommonHandler
Handler for key ‘odd’ Test that an expression represents an odd number
- class modelparameters.sympy.assumptions.handlers.ntheory.AskPrimeHandler[source]¶
Bases:
CommonHandler
Handler for key ‘prime’ Test that an expression represents a prime number. When the expression is a number the result, when True, is subject to the limitations of isprime() which is used to return the result.
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static NegativeInfinity(expr, assumptions)¶
- static Rational(expr, assumptions)¶
modelparameters.sympy.assumptions.handlers.order module¶
AskHandlers related to order relations: positive, negative, etc.
- class modelparameters.sympy.assumptions.handlers.order.AskNegativeHandler[source]¶
Bases:
CommonHandler
This is called by ask() when key=’negative’
Test that an expression is less (strict) than zero.
Examples
>>> from ... import ask, Q, pi >>> ask(Q.negative(pi+1)) # this calls AskNegativeHandler.Add False >>> ask(Q.negative(pi**2)) # this calls AskNegativeHandler.Pow False
- static Abs(expr, assumptions)¶
- static Add(expr, assumptions)[source]¶
Positive + Positive -> Positive, Negative + Negative -> Negative
- static ImaginaryUnit(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.order.AskNonNegativeHandler[source]¶
Bases:
CommonHandler
- class modelparameters.sympy.assumptions.handlers.order.AskNonPositiveHandler[source]¶
Bases:
CommonHandler
- class modelparameters.sympy.assumptions.handlers.order.AskNonZeroHandler[source]¶
Bases:
CommonHandler
Handler for key ‘zero’ Test that an expression is not identically zero
- static NaN(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.order.AskPositiveHandler[source]¶
Bases:
CommonHandler
Handler for key ‘positive’ Test that an expression is greater (strict) than zero
- static ImaginaryUnit(expr, assumptions)¶
modelparameters.sympy.assumptions.handlers.sets module¶
Handlers for predicates related to set membership: integer, rational, etc.
- class modelparameters.sympy.assumptions.handlers.sets.AskAlgebraicHandler[source]¶
Bases:
CommonHandler
Handler for Q.algebraic key.
- static AlgebraicNumber(expr, assumptions)¶
- static ComplexInfinity(expr, assumptions)¶
- static Exp1(expr, assumptions)¶
- static Float(expr, assumptions)¶
- static GoldenRatio(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static NegativeInfinity(expr, assumptions)¶
- static Pi(expr, assumptions)¶
- static acos(expr, assumptions)¶
- static acot(expr, assumptions)¶
- static asin(expr, assumptions)¶
- static atan(expr, assumptions)¶
- static cos(expr, assumptions)¶
- static sin(expr, assumptions)¶
- static tan(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.sets.AskAntiHermitianHandler[source]¶
Bases:
AskImaginaryHandler
Handler for Q.antihermitian Test that an expression belongs to the field of anti-Hermitian operators, that is, operators in the form x*I, where x is Hermitian
- static Add(expr, assumptions)[source]¶
Antihermitian + Antihermitian -> Antihermitian Antihermitian + !Antihermitian -> !Antihermitian
- class modelparameters.sympy.assumptions.handlers.sets.AskComplexHandler[source]¶
Bases:
CommonHandler
Handler for Q.complex Test that an expression belongs to the field of complex numbers
- static Abs(expr, assumptions)¶
- static Determinant(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)¶
- static NegativeInfinity(expr, assumptions)¶
- static Number(expr, assumptions)¶
- static NumberSymbol(expr, assumptions)¶
- static Pow(expr, assumptions)¶
- static Trace(expr, assumptions)¶
- static cos(expr, assumptions)¶
- static exp(expr, assumptions)¶
- static im(expr, assumptions)¶
- static log(expr, assumptions)¶
- static re(expr, assumptions)¶
- static sin(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.sets.AskExtendedRealHandler[source]¶
Bases:
AskRealHandler
Handler for Q.extended_real Test that an expression belongs to the field of extended real numbers, that is real numbers union {Infinity, -Infinity}
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)¶
Real*Real -> Real Real*Imaginary -> !Real Imaginary*Imaginary -> Real
- static NegativeInfinity(expr, assumptions)¶
- static Pow(expr, assumptions)¶
Real**Integer -> Real Positive**Real -> Real Real**(Integer/Even) -> Real if base is nonnegative Real**(Integer/Odd) -> Real Imaginary**(Integer/Even) -> Real Imaginary**(Integer/Odd) -> not Real Imaginary**Real -> ? since Real could be 0 (giving real) or 1 (giving imaginary) b**Imaginary -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b) Real**Real -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not
- class modelparameters.sympy.assumptions.handlers.sets.AskHermitianHandler[source]¶
Bases:
AskRealHandler
Handler for Q.hermitian Test that an expression belongs to the field of Hermitian operators
- static Add(expr, assumptions)[source]¶
Hermitian + Hermitian -> Hermitian Hermitian + !Hermitian -> !Hermitian
- static Mul(expr, assumptions)[source]¶
As long as there is at most only one noncommutative term: Hermitian*Hermitian -> Hermitian Hermitian*Antihermitian -> !Hermitian Antihermitian*Antihermitian -> Hermitian
- static cos(expr, assumptions)¶
- static exp(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.sets.AskImaginaryHandler[source]¶
Bases:
CommonHandler
Handler for Q.imaginary Test that an expression belongs to the field of imaginary numbers, that is, numbers in the form x*I, where x is real
- static Add(expr, assumptions)[source]¶
Imaginary + Imaginary -> Imaginary Imaginary + Complex -> ? Imaginary + Real -> !Imaginary
- static ImaginaryUnit(expr, assumptions)¶
- static NumberSymbol(expr, assumptions)¶
- static Pow(expr, assumptions)[source]¶
Imaginary**Odd -> Imaginary Imaginary**Even -> Real b**Imaginary -> !Imaginary if exponent is an integer multiple of I*pi/log(b) Imaginary**Real -> ? Positive**Real -> Real Negative**Integer -> Real Negative**(Integer/2) -> Imaginary Negative**Real -> not Imaginary if exponent is not Rational
- class modelparameters.sympy.assumptions.handlers.sets.AskIntegerHandler[source]¶
Bases:
CommonHandler
Handler for Q.integer Test that an expression belongs to the field of integer numbers
- static Add(expr, assumptions)[source]¶
Integer + Integer -> Integer Integer + !Integer -> !Integer !Integer + !Integer -> ?
- static Determinant(expr, assumptions)¶
- static Exp1(expr, assumptions)¶
- static GoldenRatio(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Integer(expr, assumptions)¶
- static Mul(expr, assumptions)[source]¶
Integer*Integer -> Integer Integer*Irrational -> !Integer Odd/Even -> !Integer Integer*Rational -> ?
- static NegativeInfinity(expr, assumptions)¶
- static Pi(expr, assumptions)¶
- static Pow(expr, assumptions)¶
Integer + Integer -> Integer Integer + !Integer -> !Integer !Integer + !Integer -> ?
- static Trace(expr, assumptions)¶
- static int(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.sets.AskIrrationalHandler[source]¶
Bases:
CommonHandler
- class modelparameters.sympy.assumptions.handlers.sets.AskRationalHandler[source]¶
Bases:
CommonHandler
Handler for Q.rational Test that an expression belongs to the field of rational numbers
- static Add(expr, assumptions)[source]¶
Rational + Rational -> Rational Rational + !Rational -> !Rational !Rational + !Rational -> ?
- static Exp1(expr, assumptions)¶
- static Float(expr, assumptions)¶
- static GoldenRatio(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)¶
Rational + Rational -> Rational Rational + !Rational -> !Rational !Rational + !Rational -> ?
- static NegativeInfinity(expr, assumptions)¶
- static Pi(expr, assumptions)¶
- static Pow(expr, assumptions)[source]¶
Rational ** Integer -> Rational Irrational ** Rational -> Irrational Rational ** Irrational -> ?
- static Rational(expr, assumptions)¶
- static acos(expr, assumptions)¶
- static acot(expr, assumptions)¶
- static asin(expr, assumptions)¶
- static atan(expr, assumptions)¶
- static cos(expr, assumptions)¶
- static sin(expr, assumptions)¶
- static tan(expr, assumptions)¶
- class modelparameters.sympy.assumptions.handlers.sets.AskRealHandler[source]¶
Bases:
CommonHandler
Handler for Q.real Test that an expression belongs to the field of real numbers
- static Abs(expr, assumptions)¶
- static Determinant(expr, assumptions)¶
- static Exp1(expr, assumptions)¶
- static Float(expr, assumptions)¶
- static GoldenRatio(expr, assumptions)¶
- static ImaginaryUnit(expr, assumptions)¶
- static Infinity(expr, assumptions)¶
- static Mul(expr, assumptions)[source]¶
Real*Real -> Real Real*Imaginary -> !Real Imaginary*Imaginary -> Real
- static NegativeInfinity(expr, assumptions)¶
- static Pi(expr, assumptions)¶
- static Pow(expr, assumptions)[source]¶
Real**Integer -> Real Positive**Real -> Real Real**(Integer/Even) -> Real if base is nonnegative Real**(Integer/Odd) -> Real Imaginary**(Integer/Even) -> Real Imaginary**(Integer/Odd) -> not Real Imaginary**Real -> ? since Real could be 0 (giving real) or 1 (giving imaginary) b**Imaginary -> Real if log(b) is imaginary and b != 0 and exponent != integer multiple of I*pi/log(b) Real**Real -> ? e.g. sqrt(-1) is imaginary and sqrt(2) is not
- static Rational(expr, assumptions)¶
- static Trace(expr, assumptions)¶
- static cos(expr, assumptions)¶
- static im(expr, assumptions)¶
- static re(expr, assumptions)¶