gemseo.utils.discipline module#
Discipline utilities.
- class DisciplineVariableProperties(current_name, current_name_without_namespace, description, original_name)[source]#
Bases:
object
The properties of a discipline variable.
- Parameters:
- class DummyBaseDiscipline(name='', input_names=(), output_names=())[source]#
Bases:
BaseDiscipline
A dummy base discipline that does nothing.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
name (str) --
The name of the discipline. If empty, use the name of the class.
By default it is set to "".
input_names (Iterable[str]) --
The names of the input variables, if any.
By default it is set to ().
output_names (Iterable[str]) --
The names of the output variables, if any.
By default it is set to ().
- execution_statistics: ExecutionStatistics#
The execution statistics of the process.
- execution_status: ExecutionStatus#
The execution status of the process.
- class DummyDiscipline(name='', input_names=(), output_names=())[source]#
Bases:
Discipline
A dummy discipline that does nothing.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
name (str) --
The name of the discipline. If empty, use the name of the class.
By default it is set to "".
input_names (Iterable[str]) --
The names of the input variables, if any.
By default it is set to ().
output_names (Iterable[str]) --
The names of the output variables, if any.
By default it is set to ().
- execution_statistics: ExecutionStatistics#
The execution statistics of the process.
- execution_status: ExecutionStatus#
The execution status of the process.
- jac: JacobianData#
The Jacobian matrices of the outputs.
The structure is
{output_name: {input_name: jacobian_matrix}}
.
- class VariableRenamer[source]#
Bases:
object
Renamer of discipline input and output variable names.
- classmethod from_csv(file_path, sep=',')[source]#
Create from a CSV file.
Structured as discipline_name, variable_name, new_variable_name.
- classmethod from_dictionary(translations)[source]#
Create from dictionaries.
- classmethod from_spreadsheet(file_path)[source]#
Create from a spreadsheet file.
Structured as discipline_name, variable_name, new_variable_name.
- Parameters:
file_path (str | Path) -- The path to the spreadsheet file.
- Returns:
A renamer.
- Return type:
Self
- classmethod from_translations(*translations)[source]#
Create from translations.
- Parameters:
*translations (VariableTranslation | tuple[str, str, str]) -- The translations of the discipline input and output variables. If
tuple
, formatted as(discipline_name, variable_name, new_variable_name)
.- Returns:
A renamer.
- Return type:
- add_translation(translation)[source]#
Add a translation.
- Parameters:
translation (VariableTranslation | tuple[str, str, str]) -- A variable translation. If tuple, formatted as
(discipline_name, variable_name, new_variable_name)
.- Raises:
ValueError -- When a variable has already been renamed.
- Return type:
None
- add_translations_by_discipline(discipline_name, variable_names_to_new_variable_names)[source]#
Add one or more translations for a given discipline.
- add_translations_by_variable(new_variable_name, discipline_names_to_variable_names)[source]#
Add one or more translations for a same variable.
- property translations: tuple[VariableTranslation, ...]#
The translations of the discipline input and output variables.
- class VariableTranslation(discipline_name, variable_name, new_variable_name)[source]#
Bases:
NamedTuple
The translation of a discipline input or output variable.
Create new instance of VariableTranslation(discipline_name, variable_name, new_variable_name)
- check_disciplines_consistency(disciplines, log_message, raise_error)[source]#
Check if disciplines are consistent.
The disciplines are consistent if each output is computed by one and only one discipline.
- Parameters:
disciplines (Iterable[Discipline]) -- The disciplines of interest.
log_message (bool) -- Whether to log a message when the disciplines are not consistent.
raise_error (bool) -- Whether to raise an error when the disciplines are not consistent.
- Returns:
Whether the disciplines are consistent.
- Raises:
ValueError -- When two disciplines compute the same output and
raise_error
isTrue
.- Return type:
- get_all_inputs(disciplines, skip_scenarios=True)[source]#
Return all the input names of the disciplines.
- Parameters:
disciplines (Iterable[Discipline]) -- The disciplines including potentially
Scenario
objects.skip_scenarios (bool) --
If
True
, skip theScenario
objects. Otherwise, consider their disciplines.By default it is set to True.
- Returns:
The names of the inputs.
- Return type:
- get_all_outputs(disciplines, skip_scenarios=True)[source]#
Return all the output names of the disciplines.
- Parameters:
disciplines (Iterable[Discipline | BaseScenario]) -- The disciplines including potentially
Scenario
objects.skip_scenarios (bool) --
If
True
, skip theScenario
objects. Otherwise, consider their disciplines.By default it is set to True.
- Returns:
The names of the outputs.
- Return type:
- get_discipline_variable_properties(discipline)[source]#
Return the properties of the input and output variables of a discipline.
- Parameters:
discipline (Discipline) -- The discipline.
- Returns:
The properties of the input variables, then the properties of the output variables.
- Return type:
tuple[dict[str, DisciplineVariableProperties], dict[str, DisciplineVariableProperties]]
- get_sub_disciplines(disciplines, recursive=False)[source]#
Determine the sub-disciplines.
This method lists the sub-disciplines' disciplines. It will list up to one level of disciplines contained inside another one unless the
recursive
argument is set toTrue
.- Parameters:
disciplines (Iterable[Discipline]) -- The disciplines from which the sub-disciplines will be determined.
recursive (bool) --
If
True
, the method will look inside any discipline that has other disciplines inside until it reaches a discipline without sub-disciplines, in this case the return value will not include any discipline that has sub-disciplines. IfFalse
, the method will list up to one level of disciplines contained inside another one, in this case the return value may include disciplines that contain sub-disciplines.By default it is set to False.
- Returns:
The sub-disciplines.
- Return type:
- rename_discipline_variables(disciplines, translators)[source]#
Rename input and output variables of disciplines.
- Parameters:
disciplines (Iterable[Discipline]) -- The disciplines.
translators (Mapping[str, Mapping[str, str]]) -- The translators of the form
{discipline_name: {variable_name: new_variable_name}}
.
- Raises:
ValueError -- when a translator uses a wrong
variable_name
.- Return type:
None