khiops.core.internals.types
Submodule of khiops.core.internals
Khiops task argument mini-type system
| CLASS | DESCRIPTION |
|---|---|
KhiopsTaskArgumentType |
An argument for a Khiops task |
BoolType |
Boolean argument type |
IntType |
Integer argument type |
FloatType |
Float argument type |
StringLikeType |
String like argument type |
AbstractListType |
Base class for ListType containers |
AbstractDictType |
Base class for DictType containers |
AbstractTupleType |
Base class for TupleTypes |
| FUNCTION | DESCRIPTION |
|---|---|
ListType |
ListType factory method |
DictType |
DictType factory method |
TupleType |
TupleType factory method |
is_simple_type |
Returns True if the type is simple |
Classes
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.
See class docstring
| METHOD | DESCRIPTION |
|---|---|
is_of_this_type |
Test if the argument belongs to this type |
check |
Raises TypeError if the argument does not belongs to this type |
short_name |
Returns a short name for this type |
to_scenario_arg |
Returns a string representation to be used in an scenario file |
Methods:
is_of_this_type(arg)
abstractmethod
classmethod
Test if the argument belongs to this type
check(arg, arg_name)
classmethod
Raises TypeError if the argument does not belongs to this type
short_name()
abstractmethod
classmethod
Returns a short name for this type
to_scenario_arg(arg)
abstractmethod
classmethod
Returns a string representation to be used in an scenario file
BoolType()
IntType()
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.
StringLikeType()
Bases: KhiopsTaskArgumentType
String like argument type
The string-like type is defined as the union of str and bytes.
AbstractListType()
Bases: KhiopsTaskArgumentType
Base class for ListType containers
See the factory method ListType.
| METHOD | DESCRIPTION |
|---|---|
get_value_type |
Return the type of the list values |
Methods:
get_value_type()
abstractmethod
classmethod
Return the type of the list values
AbstractDictType()
Bases: KhiopsTaskArgumentType
Base class for DictType containers
See the factory method DictType.
| METHOD | DESCRIPTION |
|---|---|
get_key_type |
Returns the type of the dictionary keys |
get_value_type |
Return the type of the dictionary values |
Methods:
get_key_type()
abstractmethod
classmethod
Returns the type of the dictionary keys
get_value_type()
abstractmethod
classmethod
Return the type of the dictionary values
AbstractTupleType()
Bases: KhiopsTaskArgumentType
Base class for TupleTypes
See the factory method TupleType.
| METHOD | DESCRIPTION |
|---|---|
get_value_types |
Return the types of the tuple values |
Methods:
get_value_types()
abstractmethod
classmethod
Return the types of the tuple values
Functions:
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.
| PARAMETER | DESCRIPTION |
|---|---|
value_type
|
The type for the values contained in the list.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type
|
A class which inherits from AbstractListType. |
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.
| PARAMETER | DESCRIPTION |
|---|---|
key_type
|
Type of the dictionary's keys.
TYPE:
|
value_type
|
Type of the dictionary's values.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type
|
A class which inherits from AbstractDictType. |
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.
| PARAMETER | DESCRIPTION |
|---|---|
value_types
|
Type of the tuples value types. The resulting tuple type will admit only tuples
of the same size of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
type
|
A class which inherits from AbstractTupleType. |
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.