semantique.processor.types.TypePromoter#
- class semantique.processor.types.TypePromoter(*operands, function=None, manual=None)[source]#
Worker that takes care of promoting value types during an operation.
Whenever applying an operation to an array, its value type might change. For example, when evaluating an expression (e.g. when evaluating an expression involving a comparison operator the resulting values are always binary) or applying a reducer (e.g. when counting the number of “true” values in a binary array the resulting values are discrete). This is called type promotion.
This worker takes care of the type promotion during a specified operation. It can check if the value types of the operands are supported by the operation, and if yes, determine the value type of the output of the operation.
- Parameters:
*operands – The operands of the operation. Reducer functions and univariate operators always have a single operand, while bivariate operators have two operands.
function (
str
, optional) – Name of the operation.manual (
dict
, optional) – Type promotion manual of the operation. IfNone
, the worker will try to obtain the manual from the built-inTYPE_PROMOTION_MANUALS
dictionary, using the operation name (see thefunction
parameter) as search key.
Methods
__init__
(*operands[, function, manual])check
()Check if the operation supports the operand value type(s).
promote
(obj)Promote the value type of the operation output.
Attributes
The value labels of the operands.
The value types of the operands.
The type promotion manual of the operation.
The value labels of the output.
The value type of the output.