Skip to content

aeromaps.core.gemseo

A discipline interfacing a Python function.

CustomDataConverter

Bases: SimpleGrammarDataConverter

get_value_size classmethod

get_value_size(name, value)

Return the size of a data value.

The size is typically what is returned by ndarray.size or len(list). The size of a number is 1.

Args: name: The data name. value: The data value to get the size from.

Returns: The size.

Source code in aeromaps/core/gemseo.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
@classmethod
def get_value_size(cls, name: str, value: ValueType) -> int:
    """Return the size of a data value.

    The size is typically what is returned by ``ndarray.size`` or ``len(list)``.
    The size of a number is 1.


    Args:
        name: The data name.
        value: The data value to get the size from.

    Returns:
        The size.
    """
    if isinstance(value, cls._NON_ARRAY_TYPES):
        return 1
    elif isinstance(value, (list, tuple)):
        return len(value)
    return cast("NumberArray", value).size

AeroMAPSAutoModelWrapper

AeroMAPSAutoModelWrapper(model)

Bases: AutoPyDiscipline

Wraps the AeroMAPSModel class into a discipline. Inputs and outputs are automatically declared from the model's compute() function signature.

Source code in aeromaps/core/gemseo.py
138
139
140
141
142
143
144
145
146
147
148
149
150
def __init__(self, model):
    self.model: AeroMAPSModel = model

    self.default_grammar_type = Discipline.GrammarType.SIMPLE

    super(AeroMAPSAutoModelWrapper, self).__init__(
        py_func=self.model.compute,
    )
    # self.io.data_processor = AutoDiscDataProcessor()

    self.name = model.__class__.__name__

    self.update_defaults()

AeroMAPSCustomModelWrapper

AeroMAPSCustomModelWrapper(model)

Bases: Discipline

Wraps the AeroMAPSModel class into a discipline. Inputs and outputs are declared through the attributes 'input_names' and 'output_names' of the model.

Source code in aeromaps/core/gemseo.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
def __init__(self, model):
    super().__init__()

    # Whether to skip data type validation (at your own risk)
    if getattr(model, "_skip_data_type_validation", False):
        # self.input_grammar = SimplerGrammar("InputGrammar")
        # self.output_grammar = SimplerGrammar("OutputGrammar")
        self.input_grammar._validate = lambda data, msg: True
        self.output_grammar._validate = lambda data, msg: True

    # Set input and output grammars from model attributes
    if isinstance(model.input_names, dict):
        self.input_grammar.update_from_data(model.input_names)
    else:  # assume list of names
        self.input_grammar.update_from_names(model.input_names)

    if isinstance(model.output_names, dict):
        self.output_grammar.update_from_data(model.output_names)
    else:  # assume list of names
        self.output_grammar.update_from_names(model.output_names)

    # Set the model
    self.model: AeroMAPSModel = model
    self.name = model.__class__.__name__

    # Initialize default input data
    self.update_defaults()