Update#
- class Update(keys_dict=None)[source]#
Bases:
objectInject constant key-value pairs into the sample dict.
Writes each configured
key: valuestraight intodata_dict(in place, overwriting any existing entry), then returns it. Used to seed pipeline-control keys that downstream transforms read, such as overridingindex_valid_keys(which keys subsampling transforms keep length-aligned) or declaringaux_position_keys/aux_direction_keysso geometric augmentations also transform auxiliary targets. Registered asUpdate– use this string as thetypein atransform=[...]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 likeGridSample.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']