grammar module¶
Data rules and checks for disciplines inputs/outputs validation¶
-
class
gemseo.core.grammar.
AbstractGrammar
[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
-
INPUT_GRAMMAR
= 'input'¶
-
OUTPUT_GRAMMAR
= 'output'¶
-
get_data_names
()[source]¶ Returns the list of data names
- Returns
the data names alphabetically sorted
-
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_dict, raise_exception=True)[source]¶ Loads the data dictionary in the grammar and checks it against self properties
- Parameters
data_dict – the input data
raise_exception – if False, no exception is raised when data is invalid (Default value = True)
-
-
exception
gemseo.core.grammar.
InvalidDataException
[source]¶ Bases:
Exception
Exception raised when data is not valid against grammar rules.
-
class
gemseo.core.grammar.
SimpleGrammar
(name)[source]¶ Bases:
object
A grammar instance stores the input or output data types and structure a MDODiscipline It is able to check the inputs and outputs against predefined types
Constructor
:param name : grammar name
-
check
(raise_exception=True)[source]¶ Checks local data against self properties
- Parameters
raise_exception – if False, no exception is raised when data is invalid (Default value = True)
-
get_data_names
()[source]¶ Returns the list of data names
- Returns
the data names alphabetically sorted
-
get_type_of_data_named
(data_name)[source]¶ Gets the associated type to the data named data_name
- Parameters
data_name – the name of the property
- Returns
data type associated to data_name
-
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
-
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_dict, raise_exception=True)[source]¶ Loads the data dictionary in the grammar and checks it against self properties
- Parameters
data_dict – the input data
raise_exception – if False, no exception is raised when data is invalid (Default value = True)
-