gemseo / caches

Show inherited members

memory_full_cache module

Caching module to store all the entries in memory.

class gemseo.caches.memory_full_cache.MemoryFullCache(tolerance=0.0, name=None, is_memory_shared=True)[source]

Bases: AbstractFullCache

Cache using memory to cache all the data.

Parameters:
  • is_memory_shared (bool) –

    If True, a shared memory dictionary is used to store the data, which makes the cache compatible with multiprocessing.

    By default it is set to True.

  • tolerance (float) –

    By default it is set to 0.0.

  • name (str | None) –

Warning

If is_memory_shared is False and multiple disciplines point to the same cache or the process is multi-processed, there may be duplicate computations because the cache will not be shared among the processes. This class relies on some multiprocessing features, it is therefore necessary to protect its execution with an if __name__ == '__main__': statement when working on Windows.

clear()[source]

Clear the cache.

Return type:

None

property copy: MemoryFullCache

Copy the current cache.

Returns:

A copy of the current cache.

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.

name: str

The name of the cache.

tolerance: float

The tolerance below which two input arrays are considered equal.

Examples using MemoryFullCache

Memory full cache

Memory full cache

Convert a cache to a dataset

Convert a cache to a dataset