json module¶
Data values to NumPy arrays and vice versa from a JSONGrammar
.
- class gemseo.core.data_converters.json.JSONGrammarDataConverter(grammar)[source]¶
Bases:
BaseDataConverter
Data values to NumPy arrays and vice versa from a
JSONGrammar
.- Parameters:
grammar (BaseGrammar) – The grammar providing the data types used for the conversions.
- compute_names_to_sizes(names, data)¶
Compute a mapping from data names to data value sizes.
See also
- compute_names_to_slices(names, data, names_to_sizes=mappingproxy({}))¶
Compute a mapping from data names to data value slices.
The slices are relative to a NumPy array concatenating the data values associated with these data names.
- Parameters:
- Returns:
The mapping from the data names to the data slices of the expected concatenated NumPy array. and the size of this array.
- Return type:
- convert_array_to_data(array, names_to_slices)¶
Convert a NumPy array to a data structure.
See also
- convert_array_to_value(name, array)¶
Convert a NumPy array to a data value.
- convert_data_to_array(names, data)¶
Convert a part of a data structure to a NumPy array.
See also
- Parameters:
data (Data) – The data structure.
names (Iterable[str]) – The data names which values will be concatenated.
- Returns:
The concatenated NumPy array.
- Return type:
ndarray
- convert_value_to_array(name, value)¶
Convert a data value to a NumPy array.
- static get_value_size(name, value)¶
Return the size of a data value.
The size is typically what is returned by
ndarray.size
orlen(list)
. The size of a number is 1.