MemoizePointToFieldFunction¶
- class MemoizePointToFieldFunction(*args)¶
Point to field function which caches its evaluations.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimentalsubmodule.When this function is evaluated, it calls the
PointToFieldFunctionpassed as argument, and stores the inputPointwith the resulting field values. Repeated evaluations at the same input points reuse the stored fields instead of calling the wrapped function again. The cache mechanism is enabled by default and its size is initialized by the value of theResourceMapCache-MaxSize entry.- Parameters:
- function
PointToFieldFunction Delegate function
- function
Methods
Empty the cache.
Deactivate the cache mechanism.
Activate the cache mechanism.
Accessor to the number of cache hits.
Get the number of calls of the function.
Accessor to the object's name.
Accessor to the wrapped function.
Accessor to the input points stored in the cache.
Get the description of the input vector.
Get the dimension of the input vector.
getMarginal(*args)Get the marginal(s) at given indice(s).
getName()Accessor to the object's name.
Accessor to the output fields stored in the cache.
Get the description of the output field values.
Get the dimension of the output field values.
Get the output mesh.
hasName()Test if the object is named.
Test the cache mechanism activity.
setInputDescription(inputDescription)Set the description of the input vector.
setName(name)Accessor to the object's name.
setOutputDescription(outputDescription)Set the description of the output field values.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> mesh = ot.RegularGrid(0.0, 1.0, 2) >>> f = ot.PointToFieldFunction(ot.VertexValuePointToFieldFunction(ot.SymbolicFunction(['t'], ['t']), mesh)) >>> f = otexp.MemoizePointToFieldFunction(f) >>> print(f([])) [ y0 ] 0 : [ 0 ] 1 : [ 1 ]
- __init__(*args)¶
- clearCache()¶
Empty the cache.
See also
- disableCache()¶
Deactivate the cache mechanism.
See also
- enableCache()¶
Activate the cache mechanism.
See also
- getCacheHits()¶
Accessor to the number of cache hits.
- Returns:
- hitsint
Number of evaluations served from the cache.
- getCallsNumber()¶
Get the number of calls of the function.
- Returns:
- callsNumberint
Counts the number of times the function has been called since its creation.
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getFunction()¶
Accessor to the wrapped function.
- Returns:
- function
PointToFieldFunction The wrapped function.
- function
- getInputCache()¶
Accessor to the input points stored in the cache.
- Returns:
- cacheInput
Sample The input points stored in the cache.
- cacheInput
- getInputDescription()¶
Get the description of the input vector.
- Returns:
- inputDescription
Description Description of the input vector.
- inputDescription
- getInputDimension()¶
Get the dimension of the input vector.
- Returns:
- dint
Dimension
of the input vector.
- getMarginal(*args)¶
Get the marginal(s) at given indice(s).
- Parameters:
- iint or list of ints,
Indice(s) of the marginal(s) to be extracted.
- iint or list of ints,
- Returns:
- function
PointToFieldFunction The initial function restricted to the concerned marginal(s) at the indice(s)
.
- function
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- getOutputCache()¶
Accessor to the output fields stored in the cache.
- Returns:
- cacheOutput
ProcessSample The output fields stored in the cache.
- cacheOutput
- getOutputDescription()¶
Get the description of the output field values.
- Returns:
- outputDescription
Description Description of the output field values.
- outputDescription
- getOutputDimension()¶
Get the dimension of the output field values.
- Returns:
- d’int
Dimension
of the output field values.
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- isCacheEnabled()¶
Test the cache mechanism activity.
- Returns:
- isCacheEnabledbool
Flag telling whether the cache mechanism is active.
- setInputDescription(inputDescription)¶
Set the description of the input vector.
- Parameters:
- inputDescriptionsequence of str
Description of the input vector.
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.
- setOutputDescription(outputDescription)¶
Set the description of the output field values.
- Parameters:
- outputDescriptionsequence of str
Description of the output field values.
OpenTURNS