json module¶
Data values to NumPy arrays and vice versa from a JSONGrammar
.
- class gemseo.core.data_converters.json.JSONGrammarDataConverter(grammar)[source]¶
Bases:
BaseDataConverter
[JSONGrammar
]Data values to NumPy arrays and vice versa from a
JSONGrammar
.- Parameters:
grammar (T) – 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.
- Parameters:
name (str) – The data name.
array (NumberArray) – The NumPy array to convert.
- Returns:
The data value.
- Return type:
ValueType
- 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:
NumberArray
- convert_value_to_array(name, value)¶
Convert a data value to a NumPy array.
- Parameters:
name (str) – The data name.
value (ValueType) – The data value.
- Returns:
The NumPy array.
- Return type:
NumberArray
- classmethod 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.
- is_continuous(name)¶
Check that a data item has a type that can differentiate.