gemseo / core / grammars

simple_grammar module

Most basic grammar implementation.

Classes:

SimpleGrammar(name)

Store the data named and types.

class gemseo.core.grammars.simple_grammar.SimpleGrammar(name)[source]

Bases: gemseo.core.grammars.abstract_grammar.AbstractGrammar

Store the data named and types.

Constructor.

:param name : grammar name

Methods:

check(data[, raise_exception])

Checks local data against self properties.

clear()

Clears the data to produce an empty grammar.

get_data_names()

Returns the list of data names.

get_type_of_data_named(data_name)

Gets the associated type to the data named data_name.

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.

to_simple_grammar()

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.

check(data, 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)

clear()[source]

Clears the data to produce an empty grammar.

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

initialize_from_data_names(data_names)

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

update_from(input_grammar)[source]

Adds properties coming from another grammar.

Parameters

input_grammar – the grammar to take inputs from

update_from_if_not_in(input_grammar, exclude_grammar)[source]

Adds properties coming from input_grammar if they are not in exclude_grammar.

Parameters
  • input_grammar – the grammar to take inputs from

  • exclude_grammar – exclusion grammar