memory_full_cache module¶
Caching module to avoid multiple evaluations of a discipline¶
-
class
gemseo.caches.memory_full_cache.
MemoryFullCache
(tolerance=0.0, name=None)[source]¶ Bases:
gemseo.core.cache.AbstractFullCache
Cache using memory to cache all data.
Initialize a dictionary to cache data.
Initialize cache tolerance. By default, don’t use approximate cache. It is up to the user to choose to optimize CPU time with this or not could be something like 2 * finfo(float).eps
- Parameters
tolerance (float) – Tolerance that defines if two input vectors are equal and cached data shall be returned. If 0, no approximation is made. Default: 0.
name (str) – Name of the cache.
Examples
>>> from gemseo.caches.memory_full_cache import MemoryFullCache >>> cache = MemoryFullCache()
-
clear
()[source]¶ Clear the cache
Examples
>>> from gemseo.caches.memory_full_cache import MemoryFullCache >>> from numpy import array >>> cache = MemoryFullCache() >>> for index in range(5): >>> data = {'x': array([1.])*index, 'y': array([.2])*index} >>> cache.cache_outputs(data, ['x'], data, ['y']) >>> cache.get_length() 5 >>> cache.clear() >>> cache.get_length() 0
-
property
copy
¶ Copy cache.