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.experimental submodule.

When this function is evaluated, it calls the PointToFieldFunction passed as argument, and stores the input Point with 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 the ResourceMap Cache-MaxSize entry.

Parameters:
functionPointToFieldFunction

Delegate function

Methods

clearCache()

Empty the cache.

disableCache()

Deactivate the cache mechanism.

enableCache()

Activate the cache mechanism.

getCacheHits()

Accessor to the number of cache hits.

getCallsNumber()

Get the number of calls of the function.

getClassName()

Accessor to the object's name.

getFunction()

Accessor to the wrapped function.

getInputCache()

Accessor to the input points stored in the cache.

getInputDescription()

Get the description of the input vector.

getInputDimension()

Get the dimension of the input vector.

getMarginal(*args)

Get the marginal(s) at given indice(s).

getName()

Accessor to the object's name.

getOutputCache()

Accessor to the output fields stored in the cache.

getOutputDescription()

Get the description of the output field values.

getOutputDimension()

Get the dimension of the output field values.

getOutputMesh()

Get the output mesh.

hasName()

Test if the object is named.

isCacheEnabled()

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.

disableCache()

Deactivate the cache mechanism.

enableCache()

Activate the cache mechanism.

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:
functionPointToFieldFunction

The wrapped function.

getInputCache()

Accessor to the input points stored in the cache.

Returns:
cacheInputSample

The input points stored in the cache.

getInputDescription()

Get the description of the input vector.

Returns:
inputDescriptionDescription

Description of the input vector.

getInputDimension()

Get the dimension of the input vector.

Returns:
dint

Dimension d of the input vector.

getMarginal(*args)

Get the marginal(s) at given indice(s).

Parameters:
iint or list of ints, 0 \leq i < d

Indice(s) of the marginal(s) to be extracted.

Returns:
functionPointToFieldFunction

The initial function restricted to the concerned marginal(s) at the indice(s) i.

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:
cacheOutputProcessSample

The output fields stored in the cache.

getOutputDescription()

Get the description of the output field values.

Returns:
outputDescriptionDescription

Description of the output field values.

getOutputDimension()

Get the dimension of the output field values.

Returns:
d’int

Dimension d' of the output field values.

getOutputMesh()

Get the output mesh.

Returns:
outputMeshMesh

The mesh \cM_{N'} of the output field.

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.