braintools.cogtask.identity

Contents

braintools.cogtask.identity#

braintools.cogtask.identity(key, default=None)[source]#

Create an identity encoding that passes through values directly.

Useful when the context already contains properly formatted arrays that should be used directly without transformation.

Parameters:
  • key (str) – Context key containing the array value.

  • default (Array | None) – Default value if key not found. If None, returns zeros.

Returns:

Encoder function (ctx, feature) -> np.ndarray

Return type:

Callable[[Context, Feature], Array]

Examples

>>> # Context contains pre-computed encoding
>>> ctx['custom_encoding'] = np.array([0.1, 0.5, 0.8, 0.3])
>>> inputs={'stimulus': identity('custom_encoding')}