semantique.processor.types.TypePromoter

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. If None, the worker will try to obtain the manual from the built-in TYPE_PROMOTION_MANUALS dictionary, using the operation name (see the function parameter) as search key.

__init__(*operands, function=None, manual=None)[source]#

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

input_labels

The value labels of the operands.

input_types

The value types of the operands.

manual

The type promotion manual of the operation.

output_labels

The value labels of the output.

output_type

The value type of the output.