dynode.utils.utils.vectorize_objects

dynode.utils.utils.vectorize_objects#

dynode.utils.utils.vectorize_objects(objs: ~typing.List[~typing.Any], target: str, filter: ~typing.Callable[[~typing.Any], bool] = <function <lambda>>) List[Any]#

Given a list of objects, return a list of the target attribute for each object, optionally applying a filter.

Parameters#

objsList[obj]

list of objects

targetstr

attribute name to pull from each object in objs.

filterCallable[[obj], bool], optional

function to filter the objects in objs, by default lambda _: True. if filter(obj) is False, object.target is not evaluated and excluded from returned list.

Returns#

list[Any]

Target attribute from each obj in objs such that filter(obj) is True.

Raises#

KeyError

if target is not a attribute of the obj and filter(obj) is True.