Update#

class Update(keys_dict=None)[source]#

Bases: object

Inject constant key-value pairs into the sample dict.

Writes each configured key: value straight into data_dict (in place, overwriting any existing entry), then returns it. Used to seed pipeline-control keys that downstream transforms read, such as overriding index_valid_keys (which keys subsampling transforms keep length-aligned) or declaring aux_position_keys / aux_direction_keys so geometric augmentations also transform auxiliary targets. Registered as Update – use this string as the type in a transform=[...] config list.

Parameters:

keys_dict (dict, optional) – mapping of key to constant value to assign. Defaults to an empty dict (no-op).

Note

Values are assigned by reference; they are not copied. A common use is keys_dict={"index_valid_keys": [...]} to control which point-aligned arrays survive subsampling transforms like GridSample.

Example

>>> import numpy as np
>>> from pimm.datasets.transform import Update
>>> data = {"coord": np.zeros((2, 3), dtype="f4")}
>>> out = Update(keys_dict={"aux_position_keys": ["primary_vertex"]})(data)
>>> sorted(out)  # the control key is injected into the sample dict
['aux_position_keys', 'coord']
>>> out["aux_position_keys"]
['primary_vertex']