gemseo.caches.base_full_cache module#

A base class for caches storing all data.

class BaseFullCache(tolerance=0.0, name='')[source]#

Bases: BaseCache

Base cache to store all the data, either in memory or on the disk.

See also

MemoryFullCache: store all the data in memory. HDF5Cache: store all the data in an HDF5 file.

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 like 2 * numpy.finfo(float).eps.

    By default it is set to 0.0.

  • name (str) --

    A name for the cache. If empty, use the class name.

    By default it is set to "".

cache_jacobian(input_data, jacobian_data)[source]#

Cache the input and Jacobian data.

Parameters:
  • input_data (StrKeyMapping) -- 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 (StrKeyMapping) -- The data containing the input data to cache.

  • output_data (StrKeyMapping) -- The data containing the output data to cache.

Return type:

None

clear()[source]#

Clear the cache.

Return type:

None

get_all_entries()[source]#

Return an iterator over all the entries.

The tolerance is ignored.

Yields:

The entries.

Return type:

Iterator[CacheEntry]

to_ggobi(file_path, input_names=(), output_names=())[source]#

Export the cache to an XML file for ggobi tool.

Parameters:
  • file_path (str) -- The path of the file to export the cache.

  • input_names (Iterable[str]) --

    The names of the inputs to export. If empty, export all of them.

    By default it is set to ().

  • output_names (Iterable[str]) --

    The names of the outputs to export. If empty, export all of them.

    By default it is set to ().

Return type:

None

update(other_cache)[source]#

Update from another cache.

Parameters:

other_cache (BaseFullCache) -- The cache to update the current one.

Return type:

None

property last_entry: CacheEntry#

The last cache entry.

lock: RLockType#

The lock used for both multithreading and multiprocessing.

Ensure safe multiprocessing and multithreading concurrent access to the cache.

lock_hashes: RLockType#

The lock used for both multithreading and multiprocessing.

Ensure safe multiprocessing and multithreading concurrent access to the cache.