simple_cache module¶
Caching module to store only one entry.
- class gemseo.caches.simple_cache.SimpleCache(tolerance=0.0, name=None)[source]¶
Bases:
AbstractCache
Dictionary-based cache storing a unique entry.
- Parameters:
tolerance (float) –
The tolerance below which two input arrays are considered equal:
norm(new_array-cached_array)/(1+norm(cached_array)) <= tolerance
. If this is the case for all the input names, then the cached output data shall be returned rather than re-evaluating the discipline. This tolerance could be useful to optimize CPU time. It could be something like2 * numpy.finfo(float).eps
.By default it is set to 0.0.
name (str | None) – A name for the cache. If
None
, use the class name.
- class Group(value)¶
Bases:
StrEnum
A data group.
- INPUTS = 'inputs'¶
The label for the input variables.
- JACOBIAN = 'jacobian'¶
The label for the Jacobian.
- OUTPUTS = 'outputs'¶
The label for the output variables.
- cache_jacobian(input_data, jacobian_data)[source]¶
Cache the input and Jacobian data.
- Parameters:
input_data (DataMapping) – The data containing the input data to cache.
jacobian_data (JacobianData) – The Jacobian data to cache.
- Return type:
None
- cache_outputs(input_data, output_data)[source]¶
Cache input and output data.
- Parameters:
input_data (DataMapping) – The data containing the input data to cache.
output_data (DataMapping) – The data containing the output data to cache.
- Return type:
None
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- get_all_entries()[source]¶
Return an iterator over all the entries.
The tolerance is ignored.
- Yields:
The entries.
- Return type:
Iterator[CacheEntry]
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- to_dataset(name='', categorize=True, input_names=(), output_names=())¶
Build a
Dataset
from the cache.- Parameters:
name (str) –
A name for the dataset. If empty, use the name of the cache.
By default it is set to “”.
categorize (bool) –
Whether to distinguish between the different groups of variables. Otherwise, group all the variables in
Dataset.PARAMETER_GROUP`
.By default it is set to True.
The names of the inputs to be exported. If empty, use all the inputs.
By default it is set to ().
output_names (Iterable[str]) –
The names of the outputs to be exported. If empty, use all the outputs. If an output name is also an input name, the output name is suffixed with
[out]
.By default it is set to ().
- Returns:
A dataset version of the cache.
- Return type:
- values() an object providing a view on D's values ¶
- property last_entry: CacheEntry¶
The last cache entry.