Skip to content

Math function

UnaryOperator

Bases: _expression.Expression

Binary Operator class represents each operation (ex. +,*,&,...) on _expression.Expression.

__init__(operand, uuid=None)

operation(operand) classmethod abstractmethod

Execute operation.

Examples:

Ceil.operation(4.3)
# >>> 5
Floor.operation(3.9)
# >>> 3
Log2.operation(4)
# >>> 2.0

is_operatable()

Unary operator is operatable.

Returns:

Name Type Description
bool bool

True

AbsoluteValue

Bases: UnaryOperator

Absolute value operator.

operation(operand) classmethod

operation of absolute value.

Parameters:

Name Type Description Default
operand _expression.NumericValue

operand of absolute value.

required

Returns:

Type Description
_expression.NumericValue

_expression.NumericValue: absolute value of operand.

Max

Bases: _expression.BinaryOperator

Max operator.

__init__(left, right, uuid=None)

operation(left, right) classmethod

operation of max.

Parameters:

Name Type Description Default
left _expression.Expression

left operand of max.

required
right _expression.Expression

right operand of max.

required

Returns:

Type Description
tp.Any

tp.Any: max value of left and right.

Min

Bases: _expression.BinaryOperator

Min operator.

__init__(left, right, uuid=None)

operation(left, right) classmethod

operation of min.

Parameters:

Name Type Description Default
left _expression.Expression

left operand of min.

required
right _expression.Expression

right operand of min.

required

Returns:

Type Description
tp.Any

tp.Any: min value of left and right.

Ceil

Bases: UnaryOperator

Ceil operator.

abs(term)

Absolute function.

Parameters:

Name Type Description Default
term int | float | Expression

term of absolute value.

required

Returns:

Type Description
_expression.Expression

Union[AbsoluteValue, Expression]: absolute value of term.

ceil(term)

Ceiling function.

Parameters:

Name Type Description Default
term int | float | Expression

term of ceiling function.

required

Returns:

Type Description
_expression.Expression

Union[Ceil, Expression]: ceiling value of term.

floor(term)

Floor function.

Parameters:

Name Type Description Default
term int | float | Expression

term of floor function.

required

Returns:

Type Description
_expression.Expression

Union[Floor, Expression]: floor value of term.

log2(antilog)

Log function.

Parameters:

Name Type Description Default
antilog int | float | _expression.Expression

antilog

required

$$\log_{2}\mathrm{antilog}$$

Returns:

Type Description
_expression.Expression

Log2 value

max(left, right)

Max function.

Parameters:

Name Type Description Default
left int | float | _expression.Expression

left operand of max.

required
right int | float | _expression.Expression

right operand of max.

required

Returns:

Type Description
_expression.Expression

Union[Max, Expression]: max value of left and right.

min(left, right)

Min function.

Parameters:

Name Type Description Default
left int | float | _expression.Expression

left operand of min.

required
right int | float | _expression.Expression

right operand of min.

required

Returns:

Type Description
_expression.Expression

Union[Min, Expression]: min value of left and right.


Last update: 2023年7月5日