braintools.cogtask.ctx_value#
- braintools.cogtask.ctx_value(key, default=0)[source]#
Create a dynamic value that reads directly from context.
- Parameters:
- Returns:
Value function (ctx, feature) -> value
- Return type:
Examples
>>> from braintools.cogtask import Context, Feature, ctx_value >>> spec = ctx_value('fixation_strength', default=1.0) >>> ctx = Context() >>> spec(ctx, Feature(1, 'fixation')) # key missing: default 1.0 >>> ctx['fixation_strength'] = 0.3 >>> spec(ctx, Feature(1, 'fixation')) 0.3