core.internals.types#

Submodule of khiops.core.internals

Khiops task argument mini-type system

Functions#

DictType

DictType factory method

ListType

ListType factory method

TupleType

TupleType factory method

is_simple_type

Returns True if the type is simple

Classes#

AbstractDictType

Base class for DictType containers

AbstractListType

Base class for ListType containers

AbstractTupleType

Base class for TupleTypes

BoolType

Boolean argument type

FloatType

Float argument type

IntType

Integer argument type

KhiopsTaskArgumentType

An argument for a Khiops task

StringLikeType

String like argument type

class khiops.core.internals.types.AbstractDictType#

Bases: KhiopsTaskArgumentType

Base class for DictType containers

See the factory method DictType.

abstract classmethod get_key_type()#

Returns the type of the dictionary keys

abstract classmethod get_value_type()#

Return the type of the dictionary values

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

class khiops.core.internals.types.AbstractListType#

Bases: KhiopsTaskArgumentType

Base class for ListType containers

See the factory method ListType.

abstract classmethod get_value_type()#

Return the type of the list values

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

class khiops.core.internals.types.AbstractTupleType#

Bases: KhiopsTaskArgumentType

Base class for TupleTypes

See the factory method TupleType.

abstract classmethod get_value_types()#

Return the types of the tuple values

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

class khiops.core.internals.types.BoolType#

Bases: KhiopsTaskArgumentType

Boolean argument type

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

khiops.core.internals.types.DictType(key_type, value_type)#

DictType factory method

Dicts are themselves of type dict and they contain key-value relations with fixed key and value types.

Parameters:
key_typeKhiopsTaskArgumentType

Type of the dictionary’s keys.

value_typeKhiopsTaskArgumentType

Type of the dictionary’s values.

Returns:
type

A class which inherits from AbstractDictType.

class khiops.core.internals.types.FloatType#

Bases: KhiopsTaskArgumentType

Float argument type

Note that literal int’s are valid float in this mini-type system. We accept int’s because it isn’t an error for a user to set a float argument to 2 instead of 2.0.

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

class khiops.core.internals.types.IntType#

Bases: KhiopsTaskArgumentType

Integer argument type

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

class khiops.core.internals.types.KhiopsTaskArgumentType#

Bases: ABC

An argument for a Khiops task

It provides the services to:

  • Verify that an argument belongs to the type

  • Transform the argument to an “scenario language” argument

This class is not instantiable.

classmethod check(arg, arg_name)#

Raises TypeError if the argument does not belongs to this type

abstract classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

abstract classmethod short_name()#

Returns a short name for this type

abstract classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

khiops.core.internals.types.ListType(value_type)#

ListType factory method

Lists are themselves of type list and they may contain a variable number of elements of a single type.

Parameters:
value_typeKhiopsTaskArgumentType

The type for the values contained in the list.

Returns:
type

A class which inherits from AbstractListType.

class khiops.core.internals.types.StringLikeType#

Bases: KhiopsTaskArgumentType

String like argument type

The string-like type is defined as the union of str and bytes.

classmethod is_of_this_type(arg)#

Test if the argument belongs to this type

classmethod short_name()#

Returns a short name for this type

classmethod to_scenario_arg(arg)#

Returns a string representation to be used in an scenario file

khiops.core.internals.types.TupleType(*value_types)#

TupleType factory method

Tuples are themselves of type tuple and they may contain a fixed number of elements each one with a fixed type.

Parameters:
value_typeslist of KhiopsTaskArgumentType

Type of the tuples value types. The resulting tuple type will admit only tuples of the same size of value_types.

Returns:
type

A class which inherits from AbstractTupleType.

khiops.core.internals.types.is_simple_type(arg_type)#

Returns True if the type is simple

In this mini type system simple means that they are not generic containers.