abstract_grammar module¶
Rules and checks for disciplines inputs/outputs validation.
Classes:
|
Abstract Grammar : defines the abstraction for a Grammar. |
- class gemseo.core.grammars.abstract_grammar.AbstractGrammar(name)[source]¶
Bases:
object
Abstract Grammar : defines the abstraction for a Grammar.
A grammar subclass instance stores the input or output data types and structure an MDODiscipline. It is able to check the inputs and outputs against predefined types.
Methods:
clear
()Clears the data to produce an empty grammar.
Returns the list of data names.
initialize_from_base_dict
(typical_data_dict)Initialize the grammar with types and names from a typical data entry.
initialize_from_data_names
(data_names)Initializes a Grammar from a list of data.
is_all_data_names_existing
(data_names)Checks if data_names are present in grammar.
is_data_name_existing
(data_name)Checks if data_name is present in grammar.
load_data
(data[, raise_exception])Loads the data dictionary in the grammar and checks it against self properties.
Converts to the base SimpleGrammar type.
update_from
(input_grammar)Adds properties coming from another grammar.
update_from_if_not_in
(input_grammar, …)Adds properties coming from input_grammar if they are not in exclude_grammar.
- get_data_names()[source]¶
Returns the list of data names.
- Returns
the data names alphabetically sorted
- initialize_from_base_dict(typical_data_dict)[source]¶
Initialize the grammar with types and names from a typical data entry.
- Parameters
typical_data_dict – a data dictionary keys are used as data names values are used to detect the data types
- initialize_from_data_names(data_names)[source]¶
Initializes a Grammar from a list of data. All data of the grammar will be set as arrays.
- Parameters
data_names – a data names list
- is_all_data_names_existing(data_names)[source]¶
Checks if data_names are present in grammar.
- Parameters
data_names – the data names list
- Returns
True if all data are in grammar
- is_data_name_existing(data_name)[source]¶
Checks if data_name is present in grammar.
- Parameters
data_name – the data name
- Returns
True if data is in grammar
- load_data(data, raise_exception=True)[source]¶
Loads the data dictionary in the grammar and checks it against self properties.
- Parameters
data – the input data
raise_exception – if False, no exception is raised when data is invalid (Default value = True)
- to_simple_grammar()[source]¶
Converts to the base SimpleGrammar type.
- Returns
a SimpleGrammar instance equivalent to self