scuq.operators¶
- class scuq.operators.UnitOperator[source]¶
Bases:
objectAbstract base class for unit conversion operators.
- __mul__(otherOperator)[source]¶
Perform the current operation on another operator. Another operation g(x) will be performed on this operator f(x). So that the new Operator is
- Parameters:
otherOperator – The other operator to concat.
- Returns:
The resulting operator.
- __invert__()[source]¶
Invert this operation. This method returns a new operator that represents the inversion of this operator. silblings of this class override it in order to get an effect.
- Returns:
The inverse operation of this operation.
- convert(value)[source]¶
Convert
valueaccording to the operator implementation. Subclasses must implement this method.
- __str__()[source]¶
Represent this operation by a string. silblings of this class override it in order to get an effect.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Abstract method: Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.
- class scuq.operators.LogOperator(base)[source]¶
Bases:
UnitOperatorThis class provides an interface for logarithmic operators.
- __init__(base)[source]¶
Default constructor. Initializes this operator and assigns the base to it.
- Parameters:
base – The base of the logarithm.
- __invert__()[source]¶
Invert the current operation. This method returns the inverse Operation of the current operation.
- Returns:
The inverse Operation of the current Operation.
- get_base()[source]¶
Get the base of this logarithm. This method returns the base of the logarithm.
- Returns:
The base of the logarithm
- __str__()[source]¶
Represent this operation by a string.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.
- class scuq.operators.AddOperator(offset)[source]¶
Bases:
UnitOperatorThis class provides an Interface for offset operators. This class adds a constant value to an existing Operator.
- __init__(offset)[source]¶
Default constructor. Initializes the operator and assigns the offset to the current operator.
- Parameters:
offset – The offset of this operator.
- __mul__(otherOperator)[source]¶
Perform the current operation on another operator. The current operation (adding an offset a) will be performed on another operator f(x). So that the new Operator is If the other Operator is an AddOperator, the offset is updated.
- Parameters:
otherOperator – The other operator to concat.
- Returns:
The resulting operator.
- __invert__()[source]¶
Invert the current operation. This method returns the inverse operation of the current operation.
- Returns:
The inverse operation of this operation.
- convert(value)[source]¶
Convert a value. This method performs the addition of an offset on an absolute value.
- Parameters:
value – The value to convert.
- Returns:
The converted value
- get_offset()[source]¶
Get the offset. This method returns the offset of this operator.
- Returns:
The offset of this operator
- __str__()[source]¶
Represent this operation by a string.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.
- class scuq.operators.MultiplyOperator(factor)[source]¶
Bases:
UnitOperatorThis class provides an Interface for factor operators. This class multiplies a constant with an existing Operator.
- __init__(factor)[source]¶
Default constructor. Initializes this operator and assigns the factor to the current operator.
- Parameters:
factor – The offset of this operator.
- __mul__(otherOperator)[source]¶
Perform the current operation on another operator. The current operation (muliplying by a) will be performed on another operator f(x). So that the new operator is a imes g(x). In order to avoid numerical quirks, this method checks wether the parameter is an instance of a MuliplyOperator. If yes, then only the factor is updated.
- Parameters:
otherOperator – The other operator to concat.
- Returns:
The resulting operator.
- __invert__()[source]¶
Invert the current operation. For example let this operator be a times f(x) then the inverse is frac{1}{a} times f(x) .
- Returns:
The inverse Operation of the current Operation.
- convert(value)[source]¶
Convert a value. This method performs the multiplication with an factor on an absolute value.
- Parameters:
value – The value to convert.
- Returns:
The converted value.
- get_factor()[source]¶
Get the factor. This method returns the factor of this operator.
- Returns:
The factor of this operator.
- __str__()[source]¶
Represent this operation by a string.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.
- class scuq.operators.CompoundOperator(firstOp, secondOp)[source]¶
Bases:
UnitOperatorCompose two operators and apply them in sequence.
- __init__(firstOp, secondOp)[source]¶
Default Constructor For example let the secondOp be g(x) and the firstOp be f(x) then the compound Operator models f(g(x)) .
- Parameters:
firstOp – The operator that is performed at first.
secondOp – The operator that is performed at last.
- __invert__()[source]¶
Invert the current operation. This method returns the inverse Operation of the current operation. Since this Operation is based on two Operations the operations are inverted in the reverse order. For example let this Operator model y = f(g(x)) the inverse Operator models x = g^{-1}(f^{-1}(y)).
- Returns:
The inverse operation of the current operation.
- is_linear()[source]¶
Check if the Operator is linear. This operator is linear if the underlying operators are linear.
- Returns:
Trueif both underlying operators are linear.
- convert(value)[source]¶
Convert a value. This method performs the desired operation on an absolute value.
- Parameters:
value – The value to convert.
- Returns:
the converted value
- __str__()[source]¶
Represent this operation by a string.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.
- class scuq.operators.Identity[source]¶
Bases:
UnitOperatorIdentity operator that returns values unchanged.
- __mul__(otherOperator)[source]¶
Perform the current operation on another operator. This method returns the parameter.
- Parameters:
otherOperator – The other operator to concat.
- Returns:
The other Operator.
- __invert__()[source]¶
Invert the current operation. This method returns the inverse Operation of the current operation.
- Returns:
The inverse Operation of the current Operation. have to override it in order to get any effect.
- is_linear()[source]¶
Check if the Operator is linear. Identity is a linear operator. Thus, this method always returns True.
- Returns:
True.
- convert(value)[source]¶
Convert a value. This method returns the parameter.
- Parameters:
value – The value to convert (will be returned).
- Returns:
The parameter value
- __str__()[source]¶
Represent this operation by a string.
- Returns:
A string describing this operation.
- __getstate__()[source]¶
Serialization using pickle.
- Returns:
A string that represents the serialized form of this instance.