gemseo.core.discipline.io module#
The discipline inputs and outputs.
- class IO(discipline_class, discipline_name, grammar_type, auto_detect_grammar_files=False, grammar_directory='', input_grammar_file='', output_grammar_file='')[source]#
Bases:
object
The discipline input and output data.
This class defines the input and output grammar and stores the input and output data of the last execution.
- Parameters:
discipline_class (type[Any]) -- The class of the parent discipline.
discipline_name (str) -- The name of the parent discipline.
grammar_type (GrammarType) -- The type of the grammars.
auto_detect_grammar_files (bool) --
Whether to find automatically the grammar.
By default it is set to False.
grammar_directory (Path | str) --
The path to the directory where the grammar files are.
By default it is set to "".
input_grammar_file (str | Path) --
The path to the file of the input grammar.
By default it is set to "".
output_grammar_file (str | Path) --
The path to the file of the output grammar.
By default it is set to "".
- finalize(validate)[source]#
Validate the output data.
- Parameters:
validate (bool) -- Whether to validate the (eventually post-processed) cleaned data.
- Return type:
None
- have_linear_relationships(input_names, output_names)[source]#
Check if an input-output restriction is linear.
- initialize(input_data, validate)[source]#
Initialize the data from input data.
- Parameters:
input_data (StrKeyMapping) -- The input data.
validate (bool) -- Whether to validate
input_data
.
- Return type:
None
- prepare_input_data(data)[source]#
Prepare the input data.
The missing input items that have default values are added, The items that do not exist in the input grammar are removed.
- Parameters:
data (StrKeyMapping) -- The data to be used for preparing the input data.
- Returns:
The input data.
- Return type:
StrKeyMapping
- set_linear_relationships(input_names=(), output_names=())[source]#
Set the linear relationships between the inputs and outputs.
- Parameters:
input_names (Iterable[str]) --
The input names in a linear relation with the outputs. If empty, all input names are considered.
By default it is set to ().
output_names (Iterable[str]) --
The output names in a linear relation with the inputs. If empty, all output names are considered.
By default it is set to ().
- Raises:
ValueError -- If a name is not in the grammar.
- Return type:
None
- update_output_data(output_data)[source]#
Update the output in data, taking care of the namespaces if any.
The namespaces of the output data, if any, are automatically handled: if the key of an item of
output_data
is in a namespace and the key is a name without the namespace prefix then the item will be stored with the namespace prefix.If an item of
output_data
is not an output then it is ignored.- Parameters:
output_data (StrKeyMapping) -- The output data to update
data
with.- Return type:
None
- property data: DisciplineData#
The current input and output data.
When set, the passed data are shallow copied.
- data_processor: DataProcessor | None#
A pre- and post-processor for the discipline data.
This mechanism requires that the
_run()
method of the discipline for which theIO
is an attribute uses input data, returns input data and does not use theio.data
orlocal_data
attributes.
- property grammar_type: GrammarType#
The type of grammar used for inputs and outputs.
- input_grammar: BaseGrammar#
The input grammar.
- output_grammar: BaseGrammar#
The output grammar.