smlmlp.block module

smlmlp.block(timeit=True, df_name='detections')[source]

Decorator for block functions to read values from config or Locs objects.

Parameter resolution order: 1. kwargs (explicitly provided) 2. locs.{df_name} (if locs provided) 3. config (if locs provided: locs.config, else: provided config) 4. function default

If locs is provided, config must not also be provided.

This decorator works for functions and generators. Computation time is added for each call in block.times (or locs.times if locs provided).

Parameters:
  • timeit (bool, optional) – Whether to record execution time. Default is True.

  • df_name (str, optional) – Name of the Locs dataframe used to fill function arguments. Default is 'detections'.

Returns:

Decorated function.

Return type:

function

Examples

>>> from smlmlp import block
>>> @block()
... def scaled_value(value, /, scale=1, *, offset=0, cuda=False, parallel=False):
...     return value * scale + offset, {"scale": scale}
>>> result, info = scaled_value(4, config=type("Config", (), {"scale": 3, "offset": 2})())
>>> result
14

Background

Crop

Detection

Globdetection

Globlocalization

Integrate

Loading

Localization

Registration

Signal