Skip to content

Types

Internal types

Script exposing auxiliary global variables, functions and types to provide a minimal typed structure to items.

AirlineLocation

Item that is location attribute of an airline

Source code in src/rmlab/_data/types.py
63
64
65
66
class AirlineLocation:
    """Item that is location attribute of an airline"""

    pass

BoundedItem

Bases: Item

Item whose elements are bounded. The amount of unbounded items grows with the size/space of the underlying scenario

Source code in src/rmlab/_data/types.py
69
70
71
72
class BoundedItem(Item):
    """Item whose elements are bounded. The amount of unbounded items grows with the size/space of the underlying scenario"""

    pass

CoreItem

Item initialized from direct data upload

Source code in src/rmlab/_data/types.py
51
52
53
54
class CoreItem:
    """Item initialized from direct data upload"""

    pass

CustomersModelHolder dataclass

Item associated with specific customers models

Source code in src/rmlab/_data/types.py
34
35
36
37
38
39
@dataclass
class CustomersModelHolder:
    """Item associated with specific customers models"""

    crequest_id: str
    cchoice_id: str

DerivedItem

Item initialized from other item categories

Source code in src/rmlab/_data/types.py
57
58
59
60
class DerivedItem:
    """Item initialized from other item categories"""

    pass

Item dataclass

Base class for all Item classes

Source code in src/rmlab/_data/types.py
27
28
29
30
31
@dataclass
class Item:
    """Base class for all Item classes"""

    id: str

PricingModelHolder dataclass

Item associated with specific pricing models

Source code in src/rmlab/_data/types.py
42
43
44
45
46
47
48
@dataclass
class PricingModelHolder:
    """Item associated with specific pricing models"""

    prange_id: str
    pbehavior_id: str
    poptimizer_id: str

UnboundedItem

Bases: Item

Item whose elements are unbounded. The amount of unbounded items grows with the time period of the underlying scenario, which is in general unlimited

Source code in src/rmlab/_data/types.py
75
76
77
78
class UnboundedItem(Item):
    """Item whose elements are unbounded. The amount of unbounded items grows with the time period of the underlying scenario, which is in general unlimited"""

    pass

fields_of_dataclass(category)

Return the fields of a dataclass as a list of strings.

Parameters:

NameTypeDescriptionDefault
categorytype

Class of any category

required

Returns:

TypeDescription
List[str]

List of fields as strings

Source code in src/rmlab/_data/types.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def fields_of_dataclass(category: type) -> List[str]:
    """Return the fields of a dataclass as a list of strings.

    Args:
        category (type): Class of any category

    Returns:
        List of fields as strings
    """

    flds = set()

    for base_class in inspect.getmro(category):
        if is_dataclass(base_class):
            flds.update({f.name for f in fields(base_class)})

    return list(flds)